mirror of
https://github.com/Z3Prover/z3
synced 2025-06-19 12:23:38 +00:00
merged
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
commit
9ab1210cc2
518 changed files with 21452 additions and 22650 deletions
|
@ -36,6 +36,7 @@ Revision History:
|
|||
#include"scoped_ctrl_c.h"
|
||||
#include"cancel_eh.h"
|
||||
#include"scoped_timer.h"
|
||||
#include"pp_params.hpp"
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
@ -674,8 +675,8 @@ extern "C" {
|
|||
ast_manager & m = mk_c(c)->m();
|
||||
expr * a = to_expr(_a);
|
||||
params_ref p = to_param_ref(_p);
|
||||
unsigned timeout = p.get_uint(":timeout", UINT_MAX);
|
||||
bool use_ctrl_c = p.get_bool(":ctrl-c", false);
|
||||
unsigned timeout = p.get_uint("timeout", mk_c(c)->get_timeout());
|
||||
bool use_ctrl_c = p.get_bool("ctrl_c", false);
|
||||
th_rewriter m_rw(m, p);
|
||||
expr_ref result(m);
|
||||
cancel_eh<th_rewriter> eh(m_rw);
|
||||
|
@ -833,7 +834,8 @@ extern "C" {
|
|||
break;
|
||||
case Z3_PRINT_SMTLIB_COMPLIANT: {
|
||||
ast_smt_pp pp(mk_c(c)->m());
|
||||
pp.set_simplify_implies(get_pp_default_params().m_pp_simplify_implies);
|
||||
pp_params params;
|
||||
pp.set_simplify_implies(params.simplify_implies());
|
||||
ast* a1 = to_ast(a);
|
||||
pp.set_logic(mk_c(c)->fparams().m_smtlib_logic.c_str());
|
||||
if (!is_expr(a1)) {
|
||||
|
@ -886,7 +888,8 @@ extern "C" {
|
|||
pp.set_logic(logic);
|
||||
pp.set_status(status);
|
||||
pp.add_attributes(attributes);
|
||||
pp.set_simplify_implies(get_pp_default_params().m_pp_simplify_implies);
|
||||
pp_params params;
|
||||
pp.set_simplify_implies(params.simplify_implies());
|
||||
for (unsigned i = 0; i < num_assumptions; ++i) {
|
||||
pp.add_assumption(to_expr(assumptions[i]));
|
||||
}
|
||||
|
|
|
@ -17,106 +17,99 @@ Revision History:
|
|||
--*/
|
||||
#include"z3.h"
|
||||
#include"api_context.h"
|
||||
#include"api_config_params.h"
|
||||
#include"pp.h"
|
||||
#include"api_log_macros.h"
|
||||
#include"api_util.h"
|
||||
#include"cmd_context.h"
|
||||
#include"symbol.h"
|
||||
|
||||
namespace api {
|
||||
|
||||
config_params::config_params():
|
||||
m_ini(false /* do not abort on errors */) {
|
||||
register_verbosity_level(m_ini);
|
||||
register_warning(m_ini);
|
||||
m_params.register_params(m_ini);
|
||||
register_pp_params(m_ini);
|
||||
}
|
||||
|
||||
config_params::config_params(front_end_params const & p):m_params(p) {
|
||||
register_verbosity_level(m_ini);
|
||||
register_warning(m_ini);
|
||||
register_pp_params(m_ini);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
extern std::string smt_keyword2opt_name(symbol const & opt);
|
||||
#include"gparams.h"
|
||||
#include"env_params.h"
|
||||
#include"context_params.h"
|
||||
|
||||
extern "C" {
|
||||
void Z3_API Z3_global_param_set(Z3_string param_id, Z3_string param_value) {
|
||||
memory::initialize(UINT_MAX);
|
||||
LOG_Z3_global_param_set(param_id, param_value);
|
||||
try {
|
||||
gparams::set(param_id, param_value);
|
||||
env_params::updt_params();
|
||||
}
|
||||
catch (z3_exception & ex) {
|
||||
// The error handler is only available for contexts
|
||||
// Just throw a warning.
|
||||
std::ostringstream buffer;
|
||||
buffer << "Error setting " << param_id << ", " << ex.msg();
|
||||
warning_msg(buffer.str().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void Z3_API Z3_global_param_reset_all() {
|
||||
memory::initialize(UINT_MAX);
|
||||
LOG_Z3_global_param_reset_all();
|
||||
gparams::reset();
|
||||
env_params::updt_params();
|
||||
}
|
||||
|
||||
std::string g_Z3_global_param_get_buffer;
|
||||
|
||||
Z3_bool_opt Z3_API Z3_global_param_get(Z3_string param_id, Z3_string_ptr param_value) {
|
||||
memory::initialize(UINT_MAX);
|
||||
LOG_Z3_global_param_get(param_id, param_value);
|
||||
*param_value = 0;
|
||||
try {
|
||||
g_Z3_global_param_get_buffer = gparams::get_value(param_id);
|
||||
*param_value = g_Z3_global_param_get_buffer.c_str();
|
||||
return Z3_TRUE;
|
||||
}
|
||||
catch (z3_exception & ex) {
|
||||
// The error handler is only available for contexts
|
||||
// Just throw a warning.
|
||||
std::ostringstream buffer;
|
||||
buffer << "Error setting " << param_id << ": " << ex.msg();
|
||||
warning_msg(buffer.str().c_str());
|
||||
return Z3_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
Z3_config Z3_API Z3_mk_config() {
|
||||
memory::initialize(UINT_MAX);
|
||||
LOG_Z3_mk_config();
|
||||
memory::initialize(0);
|
||||
Z3_config r = reinterpret_cast<Z3_config>(alloc(api::config_params));
|
||||
Z3_config r = reinterpret_cast<Z3_config>(alloc(context_params));
|
||||
RETURN_Z3(r);
|
||||
}
|
||||
|
||||
void Z3_API Z3_del_config(Z3_config c) {
|
||||
LOG_Z3_del_config(c);
|
||||
dealloc((reinterpret_cast<api::config_params*>(c)));
|
||||
dealloc((reinterpret_cast<context_params*>(c)));
|
||||
}
|
||||
|
||||
void Z3_API Z3_set_param_value(Z3_config c, char const * param_id, char const * param_value) {
|
||||
try {
|
||||
LOG_Z3_set_param_value(c, param_id, param_value);
|
||||
api::config_params* p = reinterpret_cast<api::config_params*>(c);
|
||||
if (param_id != 0 && param_id[0] == ':') {
|
||||
// Allow SMT2 style paramater names such as :model, :relevancy, etc
|
||||
std::string new_param_id = smt_keyword2opt_name(symbol(param_id));
|
||||
p->m_ini.set_param_value(new_param_id.c_str(), param_value);
|
||||
}
|
||||
else {
|
||||
p->m_ini.set_param_value(param_id, param_value);
|
||||
}
|
||||
LOG_Z3_set_param_value(c, param_id, param_value);
|
||||
try {
|
||||
context_params * p = reinterpret_cast<context_params*>(c);
|
||||
p->set(param_id, param_value);
|
||||
}
|
||||
catch (set_get_param_exception & ex) {
|
||||
// The error handler was not set yet.
|
||||
catch (z3_exception & ex) {
|
||||
// The error handler is only available for contexts
|
||||
// Just throw a warning.
|
||||
std::ostringstream buffer;
|
||||
buffer << "Error setting " << param_id << ", " << ex.get_msg();
|
||||
buffer << "Error setting " << param_id << ": " << ex.msg();
|
||||
warning_msg(buffer.str().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void Z3_API Z3_update_param_value(Z3_context c, Z3_string param_id, Z3_string param_value) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_update_param_value(c, param_id, param_value);
|
||||
RESET_ERROR_CODE();
|
||||
ini_params ini;
|
||||
mk_c(c)->fparams().register_params(ini);
|
||||
register_pp_params(ini);
|
||||
register_verbosity_level(ini);
|
||||
register_warning(ini);
|
||||
if (mk_c(c)->has_solver()) {
|
||||
ini.freeze();
|
||||
}
|
||||
if (param_id != 0 && param_id[0] == ':') {
|
||||
// Allow SMT2 style paramater names such as :model, :relevancy, etc
|
||||
std::string new_param_id = smt_keyword2opt_name(symbol(param_id));
|
||||
ini.set_param_value(new_param_id.c_str(), param_value);
|
||||
}
|
||||
else {
|
||||
ini.set_param_value(param_id, param_value);
|
||||
}
|
||||
memory::set_high_watermark(static_cast<size_t>(mk_c(c)->fparams().m_memory_high_watermark)*1024*1024);
|
||||
memory::set_max_size(static_cast<size_t>(mk_c(c)->fparams().m_memory_max_size)*1024*1024);
|
||||
mk_c(c)->params().set(param_id, param_value);
|
||||
Z3_CATCH;
|
||||
}
|
||||
|
||||
Z3_bool Z3_API Z3_get_param_value(Z3_context c, Z3_string param_id, Z3_string* param_value) {
|
||||
LOG_Z3_get_param_value(c, param_id, param_value);
|
||||
ini_params ini;
|
||||
mk_c(c)->fparams().register_params(ini);
|
||||
register_verbosity_level(ini);
|
||||
register_pp_params(ini);
|
||||
register_warning(ini);
|
||||
std::string param_value_s;
|
||||
if (!ini.get_param_value(param_id, param_value_s)) {
|
||||
if (param_value) *param_value = 0;
|
||||
return false;
|
||||
}
|
||||
if (param_value) {
|
||||
*param_value = mk_c(c)->mk_external_string(param_value_s);
|
||||
}
|
||||
return true;
|
||||
// TODO
|
||||
return Z3_FALSE;
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
api_config_params.h
|
||||
|
||||
Abstract:
|
||||
Configuration parameters
|
||||
|
||||
Author:
|
||||
|
||||
Leonardo de Moura (leonardo) 2012-02-29.
|
||||
|
||||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef _API_CONFIG_PARAMS_H_
|
||||
#define _API_CONFIG_PARAMS_H_
|
||||
|
||||
#include"ini_file.h"
|
||||
#include"front_end_params.h"
|
||||
|
||||
namespace api {
|
||||
|
||||
class config_params {
|
||||
public:
|
||||
ini_params m_ini;
|
||||
front_end_params m_params;
|
||||
config_params();
|
||||
config_params(front_end_params const & p);
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -18,7 +18,6 @@ Revision History:
|
|||
|
||||
--*/
|
||||
#include"api_context.h"
|
||||
#include"api_config_params.h"
|
||||
#include"smtparser.h"
|
||||
#include"version.h"
|
||||
#include"ast_pp.h"
|
||||
|
@ -54,14 +53,6 @@ namespace api {
|
|||
return static_cast<Z3_search_failure>(f);
|
||||
}
|
||||
|
||||
context::param_ini::param_ini(front_end_params & p) : m_params(p) {
|
||||
p.open_trace_file();
|
||||
}
|
||||
|
||||
context::param_ini::~param_ini() {
|
||||
m_params.close_trace_file();
|
||||
}
|
||||
|
||||
context::add_plugins::add_plugins(ast_manager & m) {
|
||||
reg_decl_plugins(m);
|
||||
}
|
||||
|
@ -88,11 +79,10 @@ namespace api {
|
|||
}
|
||||
}
|
||||
|
||||
context::context(config_params * p, bool user_ref_count):
|
||||
m_params(p ? p->m_params : front_end_params()),
|
||||
m_param_ini(m_params),
|
||||
context::context(context_params * p, bool user_ref_count):
|
||||
m_params(p != 0 ? *p : context_params()),
|
||||
m_user_ref_count(user_ref_count),
|
||||
m_manager(m_params.m_proof_mode, m_params.m_trace_stream),
|
||||
m_manager(m_params.m_proof ? PGM_FINE : PGM_DISABLED, m_params.m_trace ? m_params.m_trace_file_name.c_str() : 0),
|
||||
m_plugins(m_manager),
|
||||
m_arith_util(m_manager),
|
||||
m_bv_util(m_manager),
|
||||
|
@ -115,8 +105,6 @@ namespace api {
|
|||
//
|
||||
// Configuration parameter settings.
|
||||
//
|
||||
memory::set_high_watermark(static_cast<size_t>(m_params.m_memory_high_watermark)*1024*1024);
|
||||
memory::set_max_size(static_cast<size_t>(m_params.m_memory_max_size)*1024*1024);
|
||||
if (m_params.m_debug_ref_count) {
|
||||
m_manager.debug_ref_count();
|
||||
}
|
||||
|
@ -335,7 +323,8 @@ namespace api {
|
|||
|
||||
smt::kernel & context::get_smt_kernel() {
|
||||
if (!m_solver) {
|
||||
m_solver = alloc(smt::kernel, m_manager, m_params);
|
||||
m_fparams.updt_params(m_params);
|
||||
m_solver = alloc(smt::kernel, m_manager, m_fparams);
|
||||
}
|
||||
return *m_solver;
|
||||
}
|
||||
|
@ -420,15 +409,15 @@ extern "C" {
|
|||
|
||||
Z3_context Z3_API Z3_mk_context(Z3_config c) {
|
||||
LOG_Z3_mk_context(c);
|
||||
memory::initialize(0);
|
||||
Z3_context r = reinterpret_cast<Z3_context>(alloc(api::context, reinterpret_cast<api::config_params*>(c), false));
|
||||
memory::initialize(UINT_MAX);
|
||||
Z3_context r = reinterpret_cast<Z3_context>(alloc(api::context, reinterpret_cast<context_params*>(c), false));
|
||||
RETURN_Z3(r);
|
||||
}
|
||||
|
||||
Z3_context Z3_API Z3_mk_context_rc(Z3_config c) {
|
||||
LOG_Z3_mk_context_rc(c);
|
||||
memory::initialize(0);
|
||||
Z3_context r = reinterpret_cast<Z3_context>(alloc(api::context, reinterpret_cast<api::config_params*>(c), true));
|
||||
memory::initialize(UINT_MAX);
|
||||
Z3_context r = reinterpret_cast<Z3_context>(alloc(api::context, reinterpret_cast<context_params*>(c), true));
|
||||
RETURN_Z3(r);
|
||||
}
|
||||
|
||||
|
@ -574,11 +563,4 @@ ast_manager & Z3_API Z3_get_manager(__in Z3_context c) {
|
|||
return mk_c(c)->m();
|
||||
}
|
||||
|
||||
front_end_params& Z3_API Z3_get_parameters(__in Z3_context c) {
|
||||
return mk_c(c)->fparams();
|
||||
}
|
||||
|
||||
Z3_context Z3_mk_context_from_params(front_end_params const& p) {
|
||||
api::config_params cp(p);
|
||||
return reinterpret_cast<Z3_context>(alloc(api::context, &cp));
|
||||
}
|
||||
|
|
|
@ -28,32 +28,22 @@ Revision History:
|
|||
#include"datatype_decl_plugin.h"
|
||||
#include"dl_decl_plugin.h"
|
||||
#include"smt_kernel.h"
|
||||
#include"front_end_params.h"
|
||||
#include"smt_params.h"
|
||||
#include"event_handler.h"
|
||||
#include"tactic_manager.h"
|
||||
#include"context_params.h"
|
||||
|
||||
namespace smtlib {
|
||||
class parser;
|
||||
};
|
||||
|
||||
namespace api {
|
||||
class config_params;
|
||||
|
||||
Z3_search_failure mk_Z3_search_failure(smt::failure f);
|
||||
|
||||
|
||||
class context : public tactic_manager {
|
||||
class param_ini {
|
||||
front_end_params & m_params;
|
||||
public:
|
||||
param_ini(front_end_params & p);
|
||||
~param_ini();
|
||||
};
|
||||
|
||||
struct add_plugins { add_plugins(ast_manager & m); };
|
||||
|
||||
front_end_params m_params;
|
||||
param_ini m_param_ini;
|
||||
context_params m_params;
|
||||
bool m_user_ref_count; //!< if true, the user is responsible for managing referenc counters.
|
||||
ast_manager m_manager;
|
||||
add_plugins m_plugins;
|
||||
|
@ -62,8 +52,11 @@ namespace api {
|
|||
bv_util m_bv_util;
|
||||
datalog::dl_decl_util m_datalog_util;
|
||||
|
||||
// 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
|
||||
ast_ref_vector m_ast_trail; //!< used when m_user_ref_count == false
|
||||
unsigned_vector m_ast_lim;
|
||||
|
@ -103,11 +96,16 @@ namespace api {
|
|||
//
|
||||
// ------------------------
|
||||
|
||||
context(config_params * p, bool user_ref_count = false);
|
||||
context(context_params * p, bool user_ref_count = false);
|
||||
~context();
|
||||
|
||||
front_end_params & fparams() { return m_params; }
|
||||
ast_manager & m() { return m_manager; }
|
||||
|
||||
context_params & params() { return m_params; }
|
||||
bool produce_proofs() const { return m_manager.proofs_enabled(); }
|
||||
bool produce_models() const { return m_params.m_model; }
|
||||
bool produce_unsat_cores() const { return m_params.m_unsat_core; }
|
||||
bool use_auto_config() const { return m_params.m_auto_config; }
|
||||
unsigned get_timeout() const { return m_params.m_timeout; }
|
||||
arith_util & autil() { return m_arith_util; }
|
||||
bv_util & bvutil() { return m_bv_util; }
|
||||
datalog::dl_decl_util & datalog_util() { return m_datalog_util; }
|
||||
|
@ -168,12 +166,13 @@ namespace api {
|
|||
static void out_of_memory_handler(void * _ctx);
|
||||
|
||||
void check_sorts(ast * n);
|
||||
|
||||
// ------------------------
|
||||
//
|
||||
// Solver interface for backward compatibility
|
||||
//
|
||||
// ------------------------
|
||||
|
||||
smt_params & fparams() { return m_fparams; }
|
||||
bool has_solver() const { return m_solver != 0; }
|
||||
smt::kernel & get_smt_kernel();
|
||||
void assert_cnstr(expr * a);
|
||||
|
|
|
@ -32,7 +32,7 @@ Revision History:
|
|||
|
||||
namespace api {
|
||||
|
||||
fixedpoint_context::fixedpoint_context(ast_manager& m, front_end_params& p) :
|
||||
fixedpoint_context::fixedpoint_context(ast_manager& m, smt_params& p) :
|
||||
m_state(0),
|
||||
m_reduce_app(0),
|
||||
m_reduce_assign(0),
|
||||
|
@ -48,7 +48,7 @@ namespace api {
|
|||
if (!m.has_plugin(name)) {
|
||||
m.register_plugin(name, alloc(datalog::dl_decl_plugin));
|
||||
}
|
||||
datalog::relation_manager& r = m_context.get_rmanager();
|
||||
datalog::relation_manager& r = m_context.get_rel_context().get_rmanager();
|
||||
r.register_plugin(alloc(datalog::external_relation_plugin, *this, r));
|
||||
}
|
||||
|
||||
|
@ -265,7 +265,7 @@ extern "C" {
|
|||
RESET_ERROR_CODE();
|
||||
lbool r = l_undef;
|
||||
cancel_eh<api::fixedpoint_context> eh(*to_fixedpoint_ref(d));
|
||||
unsigned timeout = to_fixedpoint(d)->m_params.get_uint(":timeout", UINT_MAX);
|
||||
unsigned timeout = to_fixedpoint(d)->m_params.get_uint("timeout", mk_c(c)->get_timeout());
|
||||
api::context::set_interruptable(*(mk_c(c)), eh);
|
||||
{
|
||||
scoped_timer timer(timeout, &eh);
|
||||
|
@ -289,13 +289,13 @@ extern "C" {
|
|||
LOG_Z3_fixedpoint_query_relations(c, d, num_relations, relations);
|
||||
RESET_ERROR_CODE();
|
||||
lbool r = l_undef;
|
||||
unsigned timeout = to_fixedpoint(d)->m_params.get_uint(":timeout", UINT_MAX);
|
||||
unsigned timeout = to_fixedpoint(d)->m_params.get_uint("timeout", mk_c(c)->get_timeout());
|
||||
cancel_eh<api::fixedpoint_context> eh(*to_fixedpoint_ref(d));
|
||||
api::context::set_interruptable(*(mk_c(c)), eh);
|
||||
{
|
||||
scoped_timer timer(timeout, &eh);
|
||||
try {
|
||||
r = to_fixedpoint_ref(d)->ctx().dl_query(num_relations, to_func_decls(relations));
|
||||
r = to_fixedpoint_ref(d)->ctx().rel_query(num_relations, to_func_decls(relations));
|
||||
}
|
||||
catch (z3_exception& ex) {
|
||||
mk_c(c)->handle_exception(ex);
|
||||
|
@ -344,7 +344,7 @@ extern "C" {
|
|||
std::istream& s) {
|
||||
ast_manager& m = mk_c(c)->m();
|
||||
dl_collected_cmds coll(m);
|
||||
cmd_context ctx(&mk_c(c)->fparams(), false, &m);
|
||||
cmd_context ctx(false, &m);
|
||||
install_dl_collect_cmds(coll, ctx);
|
||||
ctx.set_ignore_check(true);
|
||||
if (!parse_smt2_commands(ctx, s)) {
|
||||
|
|
|
@ -21,7 +21,7 @@ Revision History:
|
|||
|
||||
#include"z3.h"
|
||||
#include"ast.h"
|
||||
#include"front_end_params.h"
|
||||
#include"smt_params.h"
|
||||
#include"dl_external_relation.h"
|
||||
#include"dl_decl_plugin.h"
|
||||
#include"smt_kernel.h"
|
||||
|
@ -40,7 +40,7 @@ namespace api {
|
|||
datalog::context m_context;
|
||||
ast_ref_vector m_trail;
|
||||
public:
|
||||
fixedpoint_context(ast_manager& m, front_end_params& p);
|
||||
fixedpoint_context(ast_manager& m, smt_params& p);
|
||||
virtual ~fixedpoint_context() {}
|
||||
family_id get_family_id() const { return const_cast<datalog::context&>(m_context).get_decl_util().get_family_id(); }
|
||||
void set_state(void* state);
|
||||
|
|
|
@ -25,6 +25,7 @@ Revision History:
|
|||
#include"model.h"
|
||||
#include"model_v2_pp.h"
|
||||
#include"model_smt2_pp.h"
|
||||
#include"model_params.hpp"
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
@ -200,7 +201,7 @@ extern "C" {
|
|||
LOG_Z3_get_as_array_func_decl(c, a);
|
||||
RESET_ERROR_CODE();
|
||||
if (is_expr(to_ast(a)) && is_app_of(to_expr(a), mk_c(c)->get_array_fid(), OP_AS_ARRAY)) {
|
||||
return of_func_decl(to_func_decl(to_app(a)->get_decl()->get_parameter(0).get_ast()));
|
||||
RETURN_Z3(of_func_decl(to_func_decl(to_app(a)->get_decl()->get_parameter(0).get_ast())));
|
||||
}
|
||||
else {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
|
@ -488,7 +489,8 @@ extern "C" {
|
|||
Z3_model m,
|
||||
Z3_ast t,
|
||||
Z3_ast * v) {
|
||||
return Z3_model_eval(c, m, t, mk_c(c)->fparams().m_model_completion, v);
|
||||
model_params p;
|
||||
return Z3_model_eval(c, m, t, p.completion(), v);
|
||||
}
|
||||
|
||||
Z3_bool Z3_API Z3_eval_func_decl(Z3_context c,
|
||||
|
@ -660,7 +662,8 @@ extern "C" {
|
|||
result.resize(result.size()-1);
|
||||
}
|
||||
else {
|
||||
model_v2_pp(buffer, *(to_model_ref(m)), mk_c(c)->fparams().m_model_partial);
|
||||
model_params p;
|
||||
model_v2_pp(buffer, *(to_model_ref(m)), p.partial());
|
||||
result = buffer.str();
|
||||
}
|
||||
return mk_c(c)->mk_external_string(result);
|
||||
|
|
|
@ -66,7 +66,7 @@ extern "C" {
|
|||
Z3_TRY;
|
||||
LOG_Z3_params_set_bool(c, p, k, v);
|
||||
RESET_ERROR_CODE();
|
||||
to_params(p)->m_params.set_bool(to_symbol(k), v != 0);
|
||||
to_params(p)->m_params.set_bool(norm_param_name(to_symbol(k)).c_str(), v != 0);
|
||||
Z3_CATCH;
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ extern "C" {
|
|||
Z3_TRY;
|
||||
LOG_Z3_params_set_uint(c, p, k, v);
|
||||
RESET_ERROR_CODE();
|
||||
to_params(p)->m_params.set_uint(to_symbol(k), v);
|
||||
to_params(p)->m_params.set_uint(norm_param_name(to_symbol(k)).c_str(), v);
|
||||
Z3_CATCH;
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ extern "C" {
|
|||
Z3_TRY;
|
||||
LOG_Z3_params_set_double(c, p, k, v);
|
||||
RESET_ERROR_CODE();
|
||||
to_params(p)->m_params.set_double(to_symbol(k), v);
|
||||
to_params(p)->m_params.set_double(norm_param_name(to_symbol(k)).c_str(), v);
|
||||
Z3_CATCH;
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ extern "C" {
|
|||
Z3_TRY;
|
||||
LOG_Z3_params_set_symbol(c, p, k, v);
|
||||
RESET_ERROR_CODE();
|
||||
to_params(p)->m_params.set_sym(to_symbol(k), to_symbol(v));
|
||||
to_params(p)->m_params.set_sym(norm_param_name(to_symbol(k)).c_str(), to_symbol(v));
|
||||
Z3_CATCH;
|
||||
}
|
||||
|
||||
|
|
|
@ -296,7 +296,7 @@ extern "C" {
|
|||
Z3_symbol const decl_names[],
|
||||
Z3_func_decl const decls[]) {
|
||||
Z3_TRY;
|
||||
cmd_context ctx(&mk_c(c)->fparams(), false, &(mk_c(c)->m()));
|
||||
cmd_context ctx(false, &(mk_c(c)->m()));
|
||||
ctx.set_ignore_check(true);
|
||||
if (exec) {
|
||||
ctx.set_solver(alloc(z3_context_solver, *mk_c(c)));
|
||||
|
@ -362,7 +362,7 @@ extern "C" {
|
|||
Z3_symbol decl_names[],
|
||||
Z3_func_decl decls[]) {
|
||||
Z3_TRY;
|
||||
cmd_context ctx(&mk_c(c)->fparams(), false, &(mk_c(c)->m()));
|
||||
cmd_context ctx(false, &(mk_c(c)->m()));
|
||||
std::string s(str);
|
||||
std::istringstream is(s);
|
||||
// No logging for this one, since it private.
|
||||
|
|
|
@ -36,11 +36,17 @@ extern "C" {
|
|||
static void init_solver_core(Z3_context c, Z3_solver _s) {
|
||||
ast_manager & m = mk_c(c)->m();
|
||||
Z3_solver_ref * s = to_solver(_s);
|
||||
s->m_solver->set_produce_proofs(m.proofs_enabled());
|
||||
s->m_solver->set_produce_unsat_cores(s->m_params.get_bool(":unsat-core", false));
|
||||
s->m_solver->set_produce_models(s->m_params.get_bool(":model", true));
|
||||
s->m_solver->set_front_end_params(mk_c(c)->fparams());
|
||||
s->m_solver->updt_params(s->m_params);
|
||||
s->m_solver->set_produce_proofs(mk_c(c)->produce_proofs());
|
||||
s->m_solver->set_produce_unsat_cores(s->m_params.get_bool("unsat_core", mk_c(c)->produce_unsat_cores()));
|
||||
s->m_solver->set_produce_models(s->m_params.get_bool("model", mk_c(c)->produce_models()));
|
||||
if (!mk_c(c)->use_auto_config()) {
|
||||
params_ref p = s->m_params;
|
||||
p.set_bool("auto_config", false);
|
||||
s->m_solver->updt_params(p);
|
||||
}
|
||||
else {
|
||||
s->m_solver->updt_params(s->m_params);
|
||||
}
|
||||
s->m_solver->init(m, s->m_logic);
|
||||
s->m_initialized = true;
|
||||
}
|
||||
|
@ -127,8 +133,8 @@ extern "C" {
|
|||
LOG_Z3_solver_set_params(c, s, p);
|
||||
RESET_ERROR_CODE();
|
||||
if (to_solver(s)->m_initialized) {
|
||||
bool old_model = to_solver(s)->m_params.get_bool(":model", true);
|
||||
bool new_model = to_param_ref(p).get_bool(":model", true);
|
||||
bool old_model = to_solver(s)->m_params.get_bool("model", true);
|
||||
bool new_model = to_param_ref(p).get_bool("model", true);
|
||||
if (old_model != new_model)
|
||||
to_solver_ref(s)->set_produce_models(new_model);
|
||||
to_solver_ref(s)->updt_params(to_param_ref(p));
|
||||
|
@ -238,8 +244,8 @@ extern "C" {
|
|||
}
|
||||
}
|
||||
expr * const * _assumptions = to_exprs(assumptions);
|
||||
unsigned timeout = to_solver(s)->m_params.get_uint(":timeout", UINT_MAX);
|
||||
bool use_ctrl_c = to_solver(s)->m_params.get_bool(":ctrl-c", false);
|
||||
unsigned timeout = to_solver(s)->m_params.get_uint("timeout", mk_c(c)->get_timeout());
|
||||
bool use_ctrl_c = to_solver(s)->m_params.get_bool("ctrl_c", false);
|
||||
cancel_eh<solver> eh(*to_solver_ref(s));
|
||||
api::context::set_interruptable(*(mk_c(c)), eh);
|
||||
lbool result;
|
||||
|
|
|
@ -404,8 +404,8 @@ extern "C" {
|
|||
Z3_apply_result_ref * ref = alloc(Z3_apply_result_ref, mk_c(c)->m());
|
||||
mk_c(c)->save_object(ref);
|
||||
|
||||
unsigned timeout = p.get_uint(":timeout", UINT_MAX);
|
||||
bool use_ctrl_c = p.get_bool(":ctrl-c", false);
|
||||
unsigned timeout = p.get_uint("timeout", UINT_MAX);
|
||||
bool use_ctrl_c = p.get_bool("ctrl_c", false);
|
||||
cancel_eh<tactic> eh(*to_tactic_ref(t));
|
||||
|
||||
to_tactic_ref(t)->updt_params(p);
|
||||
|
|
|
@ -64,6 +64,11 @@ namespace z3 {
|
|||
class apply_result;
|
||||
class fixedpoint;
|
||||
|
||||
inline void set_param(char const * param, char const * value) { Z3_global_param_set(param, value); }
|
||||
inline void set_param(char const * param, bool value) { Z3_global_param_set(param, value ? "true" : "false"); }
|
||||
inline void set_param(char const * param, int value) { std::ostringstream oss; oss << value; Z3_global_param_set(param, oss.str().c_str()); }
|
||||
inline void reset_params() { Z3_global_param_reset_all(); }
|
||||
|
||||
/**
|
||||
\brief Exception used to sign API usage errors.
|
||||
*/
|
||||
|
|
|
@ -37,7 +37,6 @@ namespace Microsoft.Z3
|
|||
|
||||
#region Internal
|
||||
internal BitVecSort(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
|
||||
internal BitVecSort(Context ctx, uint size) : base(ctx, Native.Z3_mk_bv_sort(ctx.nCtx, size)) { Contract.Requires(ctx != null); }
|
||||
#endregion
|
||||
};
|
||||
}
|
||||
|
|
|
@ -113,7 +113,6 @@ namespace Microsoft.Z3
|
|||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<BoolSort>() != null);
|
||||
|
||||
if (m_boolSort == null) m_boolSort = new BoolSort(this); return m_boolSort;
|
||||
}
|
||||
}
|
||||
|
@ -134,7 +133,14 @@ namespace Microsoft.Z3
|
|||
/// <summary>
|
||||
/// Retrieves the Real sort of the context.
|
||||
/// </summary>
|
||||
public RealSort RealSort { get { Contract.Ensures(Contract.Result<RealSort>() != null); if (m_realSort == null) m_realSort = new RealSort(this); return m_realSort; } }
|
||||
public RealSort RealSort
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<RealSort>() != null);
|
||||
if (m_realSort == null) m_realSort = new RealSort(this); return m_realSort;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new Boolean sort.
|
||||
|
@ -193,7 +199,7 @@ namespace Microsoft.Z3
|
|||
{
|
||||
Contract.Ensures(Contract.Result<BitVecSort>() != null);
|
||||
|
||||
return new BitVecSort(this, size);
|
||||
return new BitVecSort(this, Native.Z3_mk_bv_sort(nCtx, size));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -388,7 +394,7 @@ namespace Microsoft.Z3
|
|||
IntPtr[] n_constr = new IntPtr[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
{
|
||||
var constructor = c[i];
|
||||
Constructor[] constructor = c[i];
|
||||
Contract.Assume(Contract.ForAll(constructor, arr => arr != null), "Clousot does not support yet quantified formula on multidimensional arrays");
|
||||
CheckContextMatch(constructor);
|
||||
cla[i] = new ConstructorList(this, constructor);
|
||||
|
@ -3651,6 +3657,7 @@ namespace Microsoft.Z3
|
|||
Goal_DRQ.Clear(this);
|
||||
Model_DRQ.Clear(this);
|
||||
Params_DRQ.Clear(this);
|
||||
ParamDescrs_DRQ.Clear(this);
|
||||
Probe_DRQ.Clear(this);
|
||||
Solver_DRQ.Clear(this);
|
||||
Statistics_DRQ.Clear(this);
|
||||
|
|
|
@ -433,7 +433,8 @@ namespace Microsoft.Z3
|
|||
get
|
||||
{
|
||||
return (Native.Z3_is_app(Context.nCtx, NativeObject) != 0 &&
|
||||
(Z3_sort_kind)Native.Z3_get_sort_kind(Context.nCtx, Native.Z3_get_sort(Context.nCtx, NativeObject)) == Z3_sort_kind.Z3_ARRAY_SORT);
|
||||
(Z3_sort_kind)Native.Z3_get_sort_kind(Context.nCtx, Native.Z3_get_sort(Context.nCtx, NativeObject))
|
||||
== Z3_sort_kind.Z3_ARRAY_SORT);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1308,7 +1309,8 @@ namespace Microsoft.Z3
|
|||
get
|
||||
{
|
||||
return (Native.Z3_is_app(Context.nCtx, NativeObject) != 0 &&
|
||||
(Z3_sort_kind)Native.Z3_get_sort_kind(Context.nCtx, Native.Z3_get_sort(Context.nCtx, NativeObject)) == Z3_sort_kind.Z3_RELATION_SORT);
|
||||
Native.Z3_get_sort_kind(Context.nCtx, Native.Z3_get_sort(Context.nCtx, NativeObject))
|
||||
== (uint)Z3_sort_kind.Z3_RELATION_SORT);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1429,7 +1431,7 @@ namespace Microsoft.Z3
|
|||
get
|
||||
{
|
||||
return (Native.Z3_is_app(Context.nCtx, NativeObject) != 0 &&
|
||||
(Z3_sort_kind)Native.Z3_get_sort_kind(Context.nCtx, Native.Z3_get_sort(Context.nCtx, NativeObject)) == Z3_sort_kind.Z3_FINITE_DOMAIN_SORT);
|
||||
Native.Z3_get_sort_kind(Context.nCtx, Native.Z3_get_sort(Context.nCtx, NativeObject)) == (uint)Z3_sort_kind.Z3_FINITE_DOMAIN_SORT);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1489,8 +1491,8 @@ namespace Microsoft.Z3
|
|||
internal override void CheckNativeObject(IntPtr obj)
|
||||
{
|
||||
if (Native.Z3_is_app(Context.nCtx, obj) == 0 &&
|
||||
(Z3_ast_kind)Native.Z3_get_ast_kind(Context.nCtx, obj) != Z3_ast_kind.Z3_VAR_AST &&
|
||||
(Z3_ast_kind)Native.Z3_get_ast_kind(Context.nCtx, obj) != Z3_ast_kind.Z3_QUANTIFIER_AST)
|
||||
Native.Z3_get_ast_kind(Context.nCtx, obj) != (uint)Z3_ast_kind.Z3_VAR_AST &&
|
||||
Native.Z3_get_ast_kind(Context.nCtx, obj) != (uint)Z3_ast_kind.Z3_QUANTIFIER_AST)
|
||||
throw new Z3Exception("Underlying object is not a term");
|
||||
base.CheckNativeObject(obj);
|
||||
}
|
||||
|
@ -1530,7 +1532,7 @@ namespace Microsoft.Z3
|
|||
{
|
||||
case Z3_sort_kind.Z3_INT_SORT: return new IntNum(ctx, obj);
|
||||
case Z3_sort_kind.Z3_REAL_SORT: return new RatNum(ctx, obj);
|
||||
case Z3_sort_kind.Z3_BV_SORT: return new BitVecNum(ctx, obj);
|
||||
case Z3_sort_kind.Z3_BV_SORT: return new BitVecNum(ctx, obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1541,7 +1543,7 @@ namespace Microsoft.Z3
|
|||
case Z3_sort_kind.Z3_REAL_SORT: return new RealExpr(ctx, obj);
|
||||
case Z3_sort_kind.Z3_BV_SORT: return new BitVecExpr(ctx, obj);
|
||||
case Z3_sort_kind.Z3_ARRAY_SORT: return new ArrayExpr(ctx, obj);
|
||||
case Z3_sort_kind.Z3_DATATYPE_SORT: return new DatatypeExpr(ctx, obj);
|
||||
case Z3_sort_kind.Z3_DATATYPE_SORT: return new DatatypeExpr(ctx, obj);
|
||||
}
|
||||
|
||||
return new Expr(ctx, obj);
|
||||
|
|
|
@ -110,7 +110,7 @@ namespace Microsoft.Z3
|
|||
{
|
||||
Contract.Ensures(Contract.Result<Sort[]>() != null);
|
||||
|
||||
var n = DomainSize;
|
||||
uint n = DomainSize;
|
||||
|
||||
Sort[] res = new Sort[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
|
|
|
@ -184,10 +184,10 @@ namespace Microsoft.Z3
|
|||
{
|
||||
Tactic t = Context.MkTactic("simplify");
|
||||
ApplyResult res = t.Apply(this, p);
|
||||
|
||||
|
||||
if (res.NumSubgoals == 0)
|
||||
return Context.MkGoal();
|
||||
else
|
||||
throw new Z3Exception("No subgoals");
|
||||
else
|
||||
return res.Subgoals[0];
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ using System.Threading;
|
|||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
{
|
||||
[ContractClass(typeof(DecRefQueueContracts))]
|
||||
internal abstract class IDecRefQueue
|
||||
{
|
||||
|
@ -35,7 +35,7 @@ namespace Microsoft.Z3
|
|||
{
|
||||
Contract.Invariant(this.m_queue != null);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
readonly internal protected Object m_lock = new Object();
|
||||
|
|
|
@ -252,6 +252,71 @@
|
|||
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<CodeAnalysisLogFile>..\Debug\Microsoft.Z3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DocumentationFile>..\external\Microsoft.Z3.xml</DocumentationFile>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<CodeAnalysisLogFile>..\external\Microsoft.Z3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'external|x86'">
|
||||
<OutputPath>bin\x86\external\</OutputPath>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DocumentationFile>..\external\Microsoft.Z3.xml</DocumentationFile>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<CodeAnalysisLogFile>bin\Release\Microsoft.Z3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSetDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
<CodeAnalysisRuleDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release_delaysign|x86'">
|
||||
<OutputPath>bin\x86\Release_delaysign\</OutputPath>
|
||||
<DefineConstants>DELAYSIGN</DefineConstants>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DocumentationFile>..\Release_delaysign\Microsoft.Z3.xml</DocumentationFile>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<CodeAnalysisLogFile>..\release\Microsoft.Z3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSetDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
<CodeAnalysisRuleDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
|
|
|
@ -165,8 +165,8 @@ namespace Microsoft.Z3
|
|||
{
|
||||
Contract.Ensures(Contract.Result<FuncDecl[]>() != null);
|
||||
|
||||
var nFuncs = NumFuncs;
|
||||
var nConsts = NumConsts;
|
||||
uint nFuncs = NumFuncs;
|
||||
uint nConsts = NumConsts;
|
||||
uint n = nFuncs + nConsts;
|
||||
FuncDecl[] res = new FuncDecl[n];
|
||||
for (uint i = 0; i < nConsts; i++)
|
||||
|
|
|
@ -181,8 +181,6 @@ namespace Microsoft.Z3
|
|||
if (sorts.Length != names.Length)
|
||||
throw new Z3Exception("Number of sorts does not match number of names");
|
||||
|
||||
IntPtr[] _patterns = AST.ArrayToNative(patterns);
|
||||
|
||||
if (noPatterns == null && quantifierID == null && skolemID == null)
|
||||
{
|
||||
NativeObject = Native.Z3_mk_quantifier(ctx.nCtx, (isForall) ? 1 : 0, weight,
|
||||
|
|
245
src/api/java/AST.java
Normal file
245
src/api/java/AST.java
Normal file
|
@ -0,0 +1,245 @@
|
|||
/**
|
||||
* This file was automatically generated from AST.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
import com.microsoft.z3.enumerations.*;
|
||||
|
||||
/**
|
||||
* The abstract syntax tree (AST) class.
|
||||
**/
|
||||
public class AST extends Z3Object
|
||||
{
|
||||
/**
|
||||
* Comparison operator. <param name="a">An AST</param> <param name="b">An
|
||||
* AST</param>
|
||||
*
|
||||
* @return True if <paramref name="a"/> and <paramref name="b"/> are from
|
||||
* the same context and represent the same sort; false otherwise.
|
||||
**/
|
||||
/* Overloaded operators are not translated. */
|
||||
|
||||
/**
|
||||
* Comparison operator. <param name="a">An AST</param> <param name="b">An
|
||||
* AST</param>
|
||||
*
|
||||
* @return True if <paramref name="a"/> and <paramref name="b"/> are not
|
||||
* from the same context or represent different sorts; false
|
||||
* otherwise.
|
||||
**/
|
||||
/* Overloaded operators are not translated. */
|
||||
|
||||
/**
|
||||
* Object comparison.
|
||||
**/
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
AST casted = null;
|
||||
|
||||
try
|
||||
{
|
||||
casted = AST.class.cast(o);
|
||||
} catch (ClassCastException e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.NativeObject() == casted.NativeObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Object Comparison. <param name="other">Another AST</param>
|
||||
*
|
||||
* @return Negative if the object should be sorted before <paramref
|
||||
* name="other"/>, positive if after else zero.
|
||||
**/
|
||||
public int compareTo(Object other) throws Z3Exception
|
||||
{
|
||||
if (other == null)
|
||||
return 1;
|
||||
|
||||
AST oAST = null;
|
||||
try
|
||||
{
|
||||
oAST = AST.class.cast(other);
|
||||
} catch (ClassCastException e)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (Id() < oAST.Id())
|
||||
return -1;
|
||||
else if (Id() > oAST.Id())
|
||||
return +1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The AST's hash code.
|
||||
*
|
||||
* @return A hash code
|
||||
**/
|
||||
public int GetHashCode() throws Z3Exception
|
||||
{
|
||||
return (int) Native.getAstHash(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* A unique identifier for the AST (unique among all ASTs).
|
||||
**/
|
||||
public int Id() throws Z3Exception
|
||||
{
|
||||
return Native.getAstId(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates (copies) the AST to the Context <paramref name="ctx"/>. <param
|
||||
* name="ctx">A context</param>
|
||||
*
|
||||
* @return A copy of the AST which is associated with <paramref name="ctx"/>
|
||||
**/
|
||||
public AST Translate(Context ctx) throws Z3Exception
|
||||
{
|
||||
|
||||
if (Context() == ctx)
|
||||
return this;
|
||||
else
|
||||
return new AST(ctx, Native.translate(Context().nCtx(),
|
||||
NativeObject(), ctx.nCtx()));
|
||||
}
|
||||
|
||||
/**
|
||||
* The kind of the AST.
|
||||
**/
|
||||
public Z3_ast_kind ASTKind() throws Z3Exception
|
||||
{
|
||||
return Z3_ast_kind.fromInt(Native.getAstKind(Context().nCtx(),
|
||||
NativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the AST is an Expr
|
||||
**/
|
||||
public boolean IsExpr() throws Z3Exception
|
||||
{
|
||||
switch (ASTKind())
|
||||
{
|
||||
case Z3_APP_AST:
|
||||
case Z3_NUMERAL_AST:
|
||||
case Z3_QUANTIFIER_AST:
|
||||
case Z3_VAR_AST:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the AST is a BoundVariable
|
||||
**/
|
||||
public boolean IsVar() throws Z3Exception
|
||||
{
|
||||
return this.ASTKind() == Z3_ast_kind.Z3_VAR_AST;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the AST is a Quantifier
|
||||
**/
|
||||
public boolean IsQuantifier() throws Z3Exception
|
||||
{
|
||||
return this.ASTKind() == Z3_ast_kind.Z3_QUANTIFIER_AST;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the AST is a Sort
|
||||
**/
|
||||
public boolean IsSort() throws Z3Exception
|
||||
{
|
||||
return this.ASTKind() == Z3_ast_kind.Z3_SORT_AST;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the AST is a FunctionDeclaration
|
||||
**/
|
||||
public boolean IsFuncDecl() throws Z3Exception
|
||||
{
|
||||
return this.ASTKind() == Z3_ast_kind.Z3_FUNC_DECL_AST;
|
||||
}
|
||||
|
||||
/**
|
||||
* A string representation of the AST.
|
||||
**/
|
||||
public String toString()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Native.astToString(Context().nCtx(), NativeObject());
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
return "Z3Exception: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A string representation of the AST in s-expression notation.
|
||||
**/
|
||||
public String SExpr() throws Z3Exception
|
||||
{
|
||||
return Native.astToString(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
AST(Context ctx)
|
||||
{
|
||||
super(ctx);
|
||||
}
|
||||
|
||||
AST(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
void IncRef(long o) throws Z3Exception
|
||||
{
|
||||
// Console.WriteLine("AST IncRef()");
|
||||
if (Context() == null)
|
||||
throw new Z3Exception("inc() called on null context");
|
||||
if (o == 0)
|
||||
throw new Z3Exception("inc() called on null AST");
|
||||
Context().AST_DRQ().IncAndClear(Context(), o);
|
||||
super.IncRef(o);
|
||||
}
|
||||
|
||||
void DecRef(long o) throws Z3Exception
|
||||
{
|
||||
// Console.WriteLine("AST DecRef()");
|
||||
if (Context() == null)
|
||||
throw new Z3Exception("dec() called on null context");
|
||||
if (o == 0)
|
||||
throw new Z3Exception("dec() called on null AST");
|
||||
Context().AST_DRQ().Add(o);
|
||||
super.DecRef(o);
|
||||
}
|
||||
|
||||
static AST Create(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
switch (Z3_ast_kind.fromInt(Native.getAstKind(ctx.nCtx(), obj)))
|
||||
{
|
||||
case Z3_FUNC_DECL_AST:
|
||||
return new FuncDecl(ctx, obj);
|
||||
case Z3_QUANTIFIER_AST:
|
||||
return new Quantifier(ctx, obj);
|
||||
case Z3_SORT_AST:
|
||||
return Sort.Create(ctx, obj);
|
||||
case Z3_APP_AST:
|
||||
case Z3_NUMERAL_AST:
|
||||
case Z3_VAR_AST:
|
||||
return Expr.Create(ctx, obj);
|
||||
default:
|
||||
throw new Z3Exception("Unknown AST kind");
|
||||
}
|
||||
}
|
||||
}
|
31
src/api/java/ASTDecRefQueue.java
Normal file
31
src/api/java/ASTDecRefQueue.java
Normal file
|
@ -0,0 +1,31 @@
|
|||
/**
|
||||
* Copyright (c) 2012 Microsoft Corporation
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
public class ASTDecRefQueue extends IDecRefQueue
|
||||
{
|
||||
public void IncRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Native.incRef(ctx.nCtx(), obj);
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
// OK.
|
||||
}
|
||||
}
|
||||
|
||||
public void DecRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Native.decRef(ctx.nCtx(), obj);
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
// OK.
|
||||
}
|
||||
}
|
||||
};
|
124
src/api/java/ASTMap.java
Normal file
124
src/api/java/ASTMap.java
Normal file
|
@ -0,0 +1,124 @@
|
|||
/**
|
||||
* This file was automatically generated from ASTMap.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* Map from AST to AST
|
||||
**/
|
||||
class ASTMap extends Z3Object
|
||||
{
|
||||
/**
|
||||
* Checks whether the map contains the key <paramref name="k"/>. <param
|
||||
* name="k">An AST</param>
|
||||
*
|
||||
* @return True if <paramref name="k"/> is a key in the map, false
|
||||
* otherwise.
|
||||
**/
|
||||
public boolean Contains(AST k) throws Z3Exception
|
||||
{
|
||||
|
||||
return Native.astMapContains(Context().nCtx(), NativeObject(),
|
||||
k.NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the value associated with the key <paramref name="k"/>. <remarks>
|
||||
* This function signs an error when <paramref name="k"/> is not a key in
|
||||
* the map. </remarks> <param name="k">An AST</param>
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public AST Find(AST k) throws Z3Exception
|
||||
{
|
||||
return new AST(Context(), Native.astMapFind(Context().nCtx(),
|
||||
NativeObject(), k.NativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores or replaces a new key/value pair in the map. <param name="k">The
|
||||
* key AST</param> <param name="v">The value AST</param>
|
||||
**/
|
||||
public void Insert(AST k, AST v) throws Z3Exception
|
||||
{
|
||||
|
||||
Native.astMapInsert(Context().nCtx(), NativeObject(), k.NativeObject(),
|
||||
v.NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Erases the key <paramref name="k"/> from the map. <param name="k">An
|
||||
* AST</param>
|
||||
**/
|
||||
public void Erase(AST k) throws Z3Exception
|
||||
{
|
||||
|
||||
Native.astMapErase(Context().nCtx(), NativeObject(), k.NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all keys from the map.
|
||||
**/
|
||||
public void Reset() throws Z3Exception
|
||||
{
|
||||
Native.astMapReset(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* The size of the map
|
||||
**/
|
||||
public int Size() throws Z3Exception
|
||||
{
|
||||
return Native.astMapSize(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* The keys stored in the map.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public ASTVector Keys() throws Z3Exception
|
||||
{
|
||||
return new ASTVector(Context(), Native.astMapKeys(Context().nCtx(),
|
||||
NativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a string representation of the map.
|
||||
**/
|
||||
public String toString()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Native.astMapToString(Context().nCtx(), NativeObject());
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
return "Z3Exception: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
ASTMap(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
ASTMap(Context ctx) throws Z3Exception
|
||||
{
|
||||
super(ctx, Native.mkAstMap(ctx.nCtx()));
|
||||
}
|
||||
|
||||
void IncRef(long o) throws Z3Exception
|
||||
{
|
||||
Context().ASTMap_DRQ().IncAndClear(Context(), o);
|
||||
super.IncRef(o);
|
||||
}
|
||||
|
||||
void DecRef(long o) throws Z3Exception
|
||||
{
|
||||
Context().ASTMap_DRQ().Add(o);
|
||||
super.DecRef(o);
|
||||
}
|
||||
}
|
109
src/api/java/ASTVector.java
Normal file
109
src/api/java/ASTVector.java
Normal file
|
@ -0,0 +1,109 @@
|
|||
/**
|
||||
* This file was automatically generated from ASTVector.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* Vectors of ASTs.
|
||||
**/
|
||||
class ASTVector extends Z3Object
|
||||
{
|
||||
/**
|
||||
* The size of the vector
|
||||
**/
|
||||
public int Size() throws Z3Exception
|
||||
{
|
||||
return Native.astVectorSize(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the i-th object in the vector. <remarks>May throw an
|
||||
* IndexOutOfBoundsException when <paramref name="i"/> is out of
|
||||
* range.</remarks> <param name="i">Index</param>
|
||||
*
|
||||
* @return An AST
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public AST get(int i) throws Z3Exception
|
||||
{
|
||||
return new AST(Context(), Native.astVectorGet(Context().nCtx(),
|
||||
NativeObject(), i));
|
||||
}
|
||||
|
||||
public void set(int i, AST value) throws Z3Exception
|
||||
{
|
||||
|
||||
Native.astVectorSet(Context().nCtx(), NativeObject(), i,
|
||||
value.NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Resize the vector to <paramref name="newSize"/>. <param
|
||||
* name="newSize">The new size of the vector.</param>
|
||||
**/
|
||||
public void Resize(int newSize) throws Z3Exception
|
||||
{
|
||||
Native.astVectorResize(Context().nCtx(), NativeObject(), newSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the AST <paramref name="a"/> to the back of the vector. The size is
|
||||
* increased by 1. <param name="a">An AST</param>
|
||||
**/
|
||||
public void Push(AST a) throws Z3Exception
|
||||
{
|
||||
Native.astVectorPush(Context().nCtx(), NativeObject(), a.NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates all ASTs in the vector to <paramref name="ctx"/>. <param
|
||||
* name="ctx">A context</param>
|
||||
*
|
||||
* @return A new ASTVector
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public ASTVector Translate(Context ctx) throws Z3Exception
|
||||
{
|
||||
return new ASTVector(Context(), Native.astVectorTranslate(Context()
|
||||
.nCtx(), NativeObject(), ctx.nCtx()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a string representation of the vector.
|
||||
**/
|
||||
public String toString()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Native.astVectorToString(Context().nCtx(), NativeObject());
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
return "Z3Exception: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
ASTVector(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
ASTVector(Context ctx) throws Z3Exception
|
||||
{
|
||||
super(ctx, Native.mkAstVector(ctx.nCtx()));
|
||||
}
|
||||
|
||||
void IncRef(long o) throws Z3Exception
|
||||
{
|
||||
Context().ASTVector_DRQ().IncAndClear(Context(), o);
|
||||
super.IncRef(o);
|
||||
}
|
||||
|
||||
void DecRef(long o) throws Z3Exception
|
||||
{
|
||||
Context().ASTVector_DRQ().Add(o);
|
||||
super.DecRef(o);
|
||||
}
|
||||
}
|
59
src/api/java/AlgebraicNum.java
Normal file
59
src/api/java/AlgebraicNum.java
Normal file
|
@ -0,0 +1,59 @@
|
|||
/**
|
||||
* This file was automatically generated from AlgebraicNum.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* Algebraic numbers
|
||||
**/
|
||||
public class AlgebraicNum extends ArithExpr
|
||||
{
|
||||
/**
|
||||
* Return a upper bound for a given real algebraic number. The interval
|
||||
* isolating the number is smaller than 1/10^<paramref name="precision"/>.
|
||||
* <seealso cref="Expr.IsAlgebraicNumber"/> <param name="precision">the
|
||||
* precision of the result</param>
|
||||
*
|
||||
* @return A numeral Expr of sort Real
|
||||
**/
|
||||
public RatNum ToUpper(int precision) throws Z3Exception
|
||||
{
|
||||
|
||||
return new RatNum(Context(), Native.getAlgebraicNumberUpper(Context()
|
||||
.nCtx(), NativeObject(), precision));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a lower bound for the given real algebraic number. The interval
|
||||
* isolating the number is smaller than 1/10^<paramref name="precision"/>.
|
||||
* <seealso cref="Expr.IsAlgebraicNumber"/> <param name="precision"></param>
|
||||
*
|
||||
* @return A numeral Expr of sort Real
|
||||
**/
|
||||
public RatNum ToLower(int precision) throws Z3Exception
|
||||
{
|
||||
|
||||
return new RatNum(Context(), Native.getAlgebraicNumberLower(Context()
|
||||
.nCtx(), NativeObject(), precision));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation in decimal notation. <remarks>The result
|
||||
* has at most <paramref name="precision"/> decimal places.</remarks>
|
||||
**/
|
||||
public String ToDecimal(int precision) throws Z3Exception
|
||||
{
|
||||
|
||||
return Native.getNumeralDecimalString(Context().nCtx(), NativeObject(),
|
||||
precision);
|
||||
}
|
||||
|
||||
AlgebraicNum(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
|
||||
}
|
||||
}
|
82
src/api/java/ApplyResult.java
Normal file
82
src/api/java/ApplyResult.java
Normal file
|
@ -0,0 +1,82 @@
|
|||
/**
|
||||
* This file was automatically generated from ApplyResult.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* ApplyResult objects represent the result of an application of a tactic to a
|
||||
* goal. It contains the subgoals that were produced.
|
||||
**/
|
||||
public class ApplyResult extends Z3Object
|
||||
{
|
||||
/**
|
||||
* The number of Subgoals.
|
||||
**/
|
||||
public int NumSubgoals() throws Z3Exception
|
||||
{
|
||||
return Native.applyResultGetNumSubgoals(Context().nCtx(),
|
||||
NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the subgoals from the ApplyResult.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Goal[] Subgoals() throws Z3Exception
|
||||
{
|
||||
int n = NumSubgoals();
|
||||
Goal[] res = new Goal[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = new Goal(Context(), Native.applyResultGetSubgoal(Context()
|
||||
.nCtx(), NativeObject(), i));
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a model for the subgoal <paramref name="i"/> into a model for the
|
||||
* original goal <code>g</code>, that the ApplyResult was obtained from.
|
||||
*
|
||||
* @return A model for <code>g</code>
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Model ConvertModel(int i, Model m) throws Z3Exception
|
||||
{
|
||||
return new Model(Context(), Native.applyResultConvertModel(Context()
|
||||
.nCtx(), NativeObject(), i, m.NativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* A string representation of the ApplyResult.
|
||||
**/
|
||||
public String toString()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Native.applyResultToString(Context().nCtx(), NativeObject());
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
return "Z3Exception: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
ApplyResult(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
void IncRef(long o) throws Z3Exception
|
||||
{
|
||||
Context().ApplyResult_DRQ().IncAndClear(Context(), o);
|
||||
super.IncRef(o);
|
||||
}
|
||||
|
||||
void DecRef(long o) throws Z3Exception
|
||||
{
|
||||
Context().ApplyResult_DRQ().Add(o);
|
||||
super.DecRef(o);
|
||||
}
|
||||
}
|
31
src/api/java/ApplyResultDecRefQueue.java
Normal file
31
src/api/java/ApplyResultDecRefQueue.java
Normal file
|
@ -0,0 +1,31 @@
|
|||
/**
|
||||
* Copyright (c) 2012 Microsoft Corporation
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
class ApplyResultDecRefQueue extends IDecRefQueue
|
||||
{
|
||||
public void IncRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Native.applyResultIncRef(ctx.nCtx(), obj);
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
// OK.
|
||||
}
|
||||
}
|
||||
|
||||
public void DecRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Native.applyResultDecRef(ctx.nCtx(), obj);
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
// OK.
|
||||
}
|
||||
}
|
||||
};
|
26
src/api/java/ArithExpr.java
Normal file
26
src/api/java/ArithExpr.java
Normal file
|
@ -0,0 +1,26 @@
|
|||
/**
|
||||
* This file was automatically generated from ArithExpr.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
* **/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* Arithmetic expressions (int/real)
|
||||
**/
|
||||
public class ArithExpr extends Expr
|
||||
{
|
||||
/**
|
||||
* Constructor for ArithExpr </summary>
|
||||
**/
|
||||
protected ArithExpr(Context ctx)
|
||||
{
|
||||
super(ctx);
|
||||
}
|
||||
|
||||
ArithExpr(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
}
|
18
src/api/java/ArithSort.java
Normal file
18
src/api/java/ArithSort.java
Normal file
|
@ -0,0 +1,18 @@
|
|||
/**
|
||||
* This file was automatically generated from ArithSort.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* An arithmetic sort, i.e., Int or Real.
|
||||
**/
|
||||
public class ArithSort extends Sort
|
||||
{
|
||||
ArithSort(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
};
|
27
src/api/java/ArrayExpr.java
Normal file
27
src/api/java/ArrayExpr.java
Normal file
|
@ -0,0 +1,27 @@
|
|||
/**
|
||||
* This file was automatically generated from ArrayExpr.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
|
||||
/**
|
||||
* Array expressions
|
||||
**/
|
||||
public class ArrayExpr extends Expr
|
||||
{
|
||||
/**
|
||||
* Constructor for ArrayExpr </summary>
|
||||
**/
|
||||
protected ArrayExpr(Context ctx)
|
||||
{
|
||||
super(ctx);
|
||||
}
|
||||
|
||||
ArrayExpr(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
}
|
44
src/api/java/ArraySort.java
Normal file
44
src/api/java/ArraySort.java
Normal file
|
@ -0,0 +1,44 @@
|
|||
/**
|
||||
* This file was automatically generated from ArraySort.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* Array sorts.
|
||||
**/
|
||||
public class ArraySort extends Sort
|
||||
{
|
||||
/**
|
||||
* The domain of the array sort.
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Sort Domain() throws Z3Exception
|
||||
{
|
||||
return Sort.Create(Context(),
|
||||
Native.getArraySortDomain(Context().nCtx(), NativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* The range of the array sort.
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Sort Range() throws Z3Exception
|
||||
{
|
||||
return Sort.Create(Context(),
|
||||
Native.getArraySortRange(Context().nCtx(), NativeObject()));
|
||||
}
|
||||
|
||||
ArraySort(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
ArraySort(Context ctx, Sort domain, Sort range) throws Z3Exception
|
||||
{
|
||||
super(ctx, Native.mkArraySort(ctx.nCtx(), domain.NativeObject(),
|
||||
range.NativeObject()));
|
||||
}
|
||||
};
|
31
src/api/java/AstMapDecRefQueue.java
Normal file
31
src/api/java/AstMapDecRefQueue.java
Normal file
|
@ -0,0 +1,31 @@
|
|||
/**
|
||||
* Copyright (c) 2012 Microsoft Corporation
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
class ASTMapDecRefQueue extends IDecRefQueue
|
||||
{
|
||||
public void IncRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Native.astMapIncRef(ctx.nCtx(), obj);
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
// OK.
|
||||
}
|
||||
}
|
||||
|
||||
public void DecRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Native.astMapDecRef(ctx.nCtx(), obj);
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
// OK.
|
||||
}
|
||||
}
|
||||
};
|
31
src/api/java/AstVectorDecRefQueue.java
Normal file
31
src/api/java/AstVectorDecRefQueue.java
Normal file
|
@ -0,0 +1,31 @@
|
|||
/**
|
||||
* Copyright (c) 2012 Microsoft Corporation
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
class ASTVectorDecRefQueue extends IDecRefQueue
|
||||
{
|
||||
public void IncRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Native.astVectorIncRef(ctx.nCtx(), obj);
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
// OK.
|
||||
}
|
||||
}
|
||||
|
||||
public void DecRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Native.astVectorDecRef(ctx.nCtx(), obj);
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
// OK.
|
||||
}
|
||||
}
|
||||
};
|
36
src/api/java/BitVecExpr.java
Normal file
36
src/api/java/BitVecExpr.java
Normal file
|
@ -0,0 +1,36 @@
|
|||
/**
|
||||
* This file was automatically generated from BitVecExpr.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* Bit-vector expressions
|
||||
**/
|
||||
public class BitVecExpr extends Expr
|
||||
{
|
||||
|
||||
/**
|
||||
* The size of the sort of a bit-vector term.
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public int SortSize() throws Z3Exception
|
||||
{
|
||||
return ((BitVecSort) Sort()).Size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for BitVecExpr </summary>
|
||||
**/
|
||||
protected BitVecExpr(Context ctx)
|
||||
{
|
||||
super(ctx);
|
||||
}
|
||||
|
||||
BitVecExpr(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
}
|
68
src/api/java/BitVecNum.java
Normal file
68
src/api/java/BitVecNum.java
Normal file
|
@ -0,0 +1,68 @@
|
|||
/**
|
||||
* This file was automatically generated from BitVecNum.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
/**
|
||||
* Bit-vector numerals
|
||||
**/
|
||||
public class BitVecNum extends BitVecExpr
|
||||
{
|
||||
/**
|
||||
* Retrieve the int value.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public int Int() throws Z3Exception
|
||||
{
|
||||
Native.IntPtr res = new Native.IntPtr();
|
||||
if (Native.getNumeralInt(Context().nCtx(), NativeObject(), res) ^ true)
|
||||
throw new Z3Exception("Numeral is not an int");
|
||||
return res.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the 64-bit int value.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public long Long() throws Z3Exception
|
||||
{
|
||||
Native.LongPtr res = new Native.LongPtr();
|
||||
if (Native.getNumeralInt64(Context().nCtx(), NativeObject(), res) ^ true)
|
||||
throw new Z3Exception("Numeral is not an int64");
|
||||
return res.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the BigInteger value.
|
||||
**/
|
||||
public BigInteger BigInteger()
|
||||
{
|
||||
return new BigInteger(this.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the numeral.
|
||||
**/
|
||||
public String toString()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Native.getNumeralString(Context().nCtx(), NativeObject());
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
return "Z3Exception: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
BitVecNum(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
}
|
25
src/api/java/BitVecSort.java
Normal file
25
src/api/java/BitVecSort.java
Normal file
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* This file was automatically generated from BitVecSort.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* Bit-vector sorts.
|
||||
**/
|
||||
public class BitVecSort extends Sort
|
||||
{
|
||||
/**
|
||||
* The size of the bit-vector sort.
|
||||
**/
|
||||
public int Size() throws Z3Exception
|
||||
{
|
||||
return Native.getBvSortSize(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
BitVecSort(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
};
|
30
src/api/java/BoolExpr.java
Normal file
30
src/api/java/BoolExpr.java
Normal file
|
@ -0,0 +1,30 @@
|
|||
/**
|
||||
* This file was automatically generated from BoolExpr.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* Boolean expressions
|
||||
**/
|
||||
public class BoolExpr extends Expr
|
||||
{
|
||||
/**
|
||||
* Constructor for BoolExpr </summary>
|
||||
**/
|
||||
protected BoolExpr(Context ctx)
|
||||
{
|
||||
super(ctx);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for BoolExpr </summary>
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
BoolExpr(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
}
|
16
src/api/java/BoolSort.java
Normal file
16
src/api/java/BoolSort.java
Normal file
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
* This file was automatically generated from BoolSort.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* A Boolean sort.
|
||||
**/
|
||||
public class BoolSort extends Sort
|
||||
{
|
||||
BoolSort(Context ctx, long obj) throws Z3Exception { super(ctx, obj); { }}
|
||||
BoolSort(Context ctx) throws Z3Exception { super(ctx, Native.mkBoolSort(ctx.nCtx())); { }}
|
||||
};
|
107
src/api/java/Constructor.java
Normal file
107
src/api/java/Constructor.java
Normal file
|
@ -0,0 +1,107 @@
|
|||
/**
|
||||
* This file was automatically generated from Constructor.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* Constructors are used for datatype sorts.
|
||||
**/
|
||||
public class Constructor extends Z3Object
|
||||
{
|
||||
/**
|
||||
* The number of fields of the constructor.
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public int NumFields() throws Z3Exception
|
||||
{
|
||||
init();
|
||||
return n;
|
||||
}
|
||||
|
||||
/**
|
||||
* The function declaration of the constructor.
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public FuncDecl ConstructorDecl() throws Z3Exception
|
||||
{
|
||||
init();
|
||||
return m_constructorDecl;
|
||||
}
|
||||
|
||||
/**
|
||||
* The function declaration of the tester.
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public FuncDecl TesterDecl() throws Z3Exception
|
||||
{
|
||||
init();
|
||||
return m_testerDecl;
|
||||
}
|
||||
|
||||
/**
|
||||
* The function declarations of the accessors
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public FuncDecl[] AccessorDecls() throws Z3Exception
|
||||
{
|
||||
init();
|
||||
return m_accessorDecls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
**/
|
||||
protected void finalize() throws Z3Exception
|
||||
{
|
||||
Native.delConstructor(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
private int n = 0;
|
||||
private FuncDecl m_testerDecl = null;
|
||||
private FuncDecl m_constructorDecl = null;
|
||||
private FuncDecl[] m_accessorDecls = null;
|
||||
|
||||
Constructor(Context ctx, Symbol name, Symbol recognizer,
|
||||
Symbol[] fieldNames, Sort[] sorts, int[] sortRefs)
|
||||
throws Z3Exception
|
||||
{
|
||||
super(ctx);
|
||||
|
||||
n = AST.ArrayLength(fieldNames);
|
||||
|
||||
if (n != AST.ArrayLength(sorts))
|
||||
throw new Z3Exception(
|
||||
"Number of field names does not match number of sorts");
|
||||
if (sortRefs != null && sortRefs.length != n)
|
||||
throw new Z3Exception(
|
||||
"Number of field names does not match number of sort refs");
|
||||
|
||||
if (sortRefs == null)
|
||||
sortRefs = new int[n];
|
||||
|
||||
setNativeObject(Native.mkConstructor(ctx.nCtx(), name.NativeObject(),
|
||||
recognizer.NativeObject(), n, Symbol.ArrayToNative(fieldNames),
|
||||
Sort.ArrayToNative(sorts), sortRefs));
|
||||
|
||||
}
|
||||
|
||||
private void init() throws Z3Exception
|
||||
{
|
||||
if (m_testerDecl != null)
|
||||
return;
|
||||
Native.LongPtr constructor = new Native.LongPtr();
|
||||
Native.LongPtr tester = new Native.LongPtr();
|
||||
long[] accessors = new long[n];
|
||||
Native.queryConstructor(Context().nCtx(), NativeObject(), n,
|
||||
constructor, tester, accessors);
|
||||
m_constructorDecl = new FuncDecl(Context(), constructor.value);
|
||||
m_testerDecl = new FuncDecl(Context(), tester.value);
|
||||
m_accessorDecls = new FuncDecl[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
m_accessorDecls[i] = new FuncDecl(Context(), accessors[i]);
|
||||
}
|
||||
|
||||
}
|
35
src/api/java/ConstructorList.java
Normal file
35
src/api/java/ConstructorList.java
Normal file
|
@ -0,0 +1,35 @@
|
|||
/**
|
||||
* This file was automatically generated from ConstructorList.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* Lists of constructors
|
||||
**/
|
||||
public class ConstructorList extends Z3Object
|
||||
{
|
||||
/**
|
||||
* Destructor.
|
||||
**/
|
||||
protected void finalize() throws Z3Exception
|
||||
{
|
||||
Native.delConstructorList(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
ConstructorList(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
ConstructorList(Context ctx, Constructor[] constructors) throws Z3Exception
|
||||
{
|
||||
super(ctx);
|
||||
|
||||
setNativeObject(Native.mkConstructorList(Context().nCtx(),
|
||||
(int) constructors.length,
|
||||
Constructor.ArrayToNative(constructors)));
|
||||
}
|
||||
}
|
3102
src/api/java/Context.java
Normal file
3102
src/api/java/Context.java
Normal file
File diff suppressed because it is too large
Load diff
26
src/api/java/DatatypeExpr.java
Normal file
26
src/api/java/DatatypeExpr.java
Normal file
|
@ -0,0 +1,26 @@
|
|||
/**
|
||||
* This file was automatically generated from DatatypeExpr.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* Datatype expressions
|
||||
**/
|
||||
public class DatatypeExpr extends Expr
|
||||
{
|
||||
/**
|
||||
* Constructor for DatatypeExpr </summary>
|
||||
**/
|
||||
protected DatatypeExpr(Context ctx)
|
||||
{
|
||||
super(ctx);
|
||||
}
|
||||
|
||||
DatatypeExpr(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
}
|
91
src/api/java/DatatypeSort.java
Normal file
91
src/api/java/DatatypeSort.java
Normal file
|
@ -0,0 +1,91 @@
|
|||
/**
|
||||
* This file was automatically generated from DatatypeSort.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* Datatype sorts.
|
||||
**/
|
||||
public class DatatypeSort extends Sort
|
||||
{
|
||||
/**
|
||||
* The number of constructors of the datatype sort.
|
||||
**/
|
||||
public int NumConstructors() throws Z3Exception
|
||||
{
|
||||
return Native.getDatatypeSortNumConstructors(Context().nCtx(),
|
||||
NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* The constructors.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public FuncDecl[] Constructors() throws Z3Exception
|
||||
{
|
||||
int n = NumConstructors();
|
||||
FuncDecl[] res = new FuncDecl[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = new FuncDecl(Context(), Native.getDatatypeSortConstructor(
|
||||
Context().nCtx(), NativeObject(), i));
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* The recognizers.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public FuncDecl[] Recognizers() throws Z3Exception
|
||||
{
|
||||
int n = NumConstructors();
|
||||
FuncDecl[] res = new FuncDecl[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = new FuncDecl(Context(), Native.getDatatypeSortRecognizer(
|
||||
Context().nCtx(), NativeObject(), i));
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* The constructor accessors.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public FuncDecl[][] Accessors() throws Z3Exception
|
||||
{
|
||||
|
||||
int n = NumConstructors();
|
||||
FuncDecl[][] res = new FuncDecl[n][];
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
FuncDecl fd = new FuncDecl(Context(),
|
||||
Native.getDatatypeSortConstructor(Context().nCtx(),
|
||||
NativeObject(), i));
|
||||
int ds = fd.DomainSize();
|
||||
FuncDecl[] tmp = new FuncDecl[ds];
|
||||
for (int j = 0; j < ds; j++)
|
||||
tmp[j] = new FuncDecl(Context(),
|
||||
Native.getDatatypeSortConstructorAccessor(Context()
|
||||
.nCtx(), NativeObject(), i, j));
|
||||
res[i] = tmp;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
DatatypeSort(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
DatatypeSort(Context ctx, Symbol name, Constructor[] constructors)
|
||||
throws Z3Exception
|
||||
{
|
||||
super(ctx, Native.mkDatatype(ctx.nCtx(), name.NativeObject(),
|
||||
(int) constructors.length, ArrayToNative(constructors)));
|
||||
|
||||
}
|
||||
};
|
61
src/api/java/EnumSort.java
Normal file
61
src/api/java/EnumSort.java
Normal file
|
@ -0,0 +1,61 @@
|
|||
/**
|
||||
* This file was automatically generated from EnumSort.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* Enumeration sorts.
|
||||
**/
|
||||
public class EnumSort extends Sort
|
||||
{
|
||||
/**
|
||||
* The function declarations of the constants in the enumeration.
|
||||
**/
|
||||
public FuncDecl[] ConstDecls()
|
||||
{
|
||||
return _constdecls;
|
||||
}
|
||||
|
||||
/**
|
||||
* The constants in the enumeration.
|
||||
**/
|
||||
public Expr[] Consts()
|
||||
{
|
||||
return _consts;
|
||||
}
|
||||
|
||||
/**
|
||||
* The test predicates for the constants in the enumeration.
|
||||
**/
|
||||
public FuncDecl[] TesterDecls()
|
||||
{
|
||||
return _testerdecls;
|
||||
}
|
||||
|
||||
private FuncDecl[] _constdecls = null, _testerdecls = null;
|
||||
private Expr[] _consts = null;
|
||||
|
||||
EnumSort(Context ctx, Symbol name, Symbol[] enumNames) throws Z3Exception
|
||||
{
|
||||
super(ctx);
|
||||
|
||||
int n = enumNames.length;
|
||||
long[] n_constdecls = new long[n];
|
||||
long[] n_testers = new long[n];
|
||||
setNativeObject(Native.mkEnumerationSort(ctx.nCtx(),
|
||||
name.NativeObject(), (int) n, Symbol.ArrayToNative(enumNames),
|
||||
n_constdecls, n_testers));
|
||||
_constdecls = new FuncDecl[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
_constdecls[i] = new FuncDecl(ctx, n_constdecls[i]);
|
||||
_testerdecls = new FuncDecl[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
_testerdecls[i] = new FuncDecl(ctx, n_testers[i]);
|
||||
_consts = new Expr[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
_consts[i] = ctx.MkApp(_constdecls[i], (Expr[])null);
|
||||
}
|
||||
};
|
1812
src/api/java/Expr.java
Normal file
1812
src/api/java/Expr.java
Normal file
File diff suppressed because it is too large
Load diff
34
src/api/java/FiniteDomainSort.java
Normal file
34
src/api/java/FiniteDomainSort.java
Normal file
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
* This file was automatically generated from FiniteDomainSort.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* Finite domain sorts.
|
||||
**/
|
||||
public class FiniteDomainSort extends Sort
|
||||
{
|
||||
/**
|
||||
* The size of the finite domain sort.
|
||||
**/
|
||||
public long Size() throws Z3Exception
|
||||
{
|
||||
Native.LongPtr res = new Native.LongPtr();
|
||||
Native.getFiniteDomainSortSize(Context().nCtx(), NativeObject(), res);
|
||||
return res.value;
|
||||
}
|
||||
|
||||
FiniteDomainSort(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
FiniteDomainSort(Context ctx, Symbol name, long size) throws Z3Exception
|
||||
{
|
||||
super(ctx, Native.mkFiniteDomainSort(ctx.nCtx(), name.NativeObject(),
|
||||
size));
|
||||
}
|
||||
}
|
333
src/api/java/Fixedpoint.java
Normal file
333
src/api/java/Fixedpoint.java
Normal file
|
@ -0,0 +1,333 @@
|
|||
/**
|
||||
* This file was automatically generated from Fixedpoint.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
import com.microsoft.z3.enumerations.*;
|
||||
|
||||
/**
|
||||
* Object for managing fixedpoints
|
||||
**/
|
||||
public class Fixedpoint extends Z3Object
|
||||
{
|
||||
|
||||
/**
|
||||
* A string that describes all available fixedpoint solver parameters.
|
||||
**/
|
||||
public String Help() throws Z3Exception
|
||||
{
|
||||
return Native.fixedpointGetHelp(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the fixedpoint solver parameters.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public void setParameters(Params value) throws Z3Exception
|
||||
{
|
||||
|
||||
Context().CheckContextMatch(value);
|
||||
Native.fixedpointSetParams(Context().nCtx(), NativeObject(),
|
||||
value.NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves parameter descriptions for Fixedpoint solver.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public ParamDescrs ParameterDescriptions() throws Z3Exception
|
||||
{
|
||||
return new ParamDescrs(Context(), Native.fixedpointGetParamDescrs(
|
||||
Context().nCtx(), NativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert a constraint (or multiple) into the fixedpoint solver.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public void Assert(BoolExpr[] constraints) throws Z3Exception
|
||||
{
|
||||
Context().CheckContextMatch(constraints);
|
||||
for (BoolExpr a : constraints)
|
||||
{
|
||||
Native.fixedpointAssert(Context().nCtx(), NativeObject(),
|
||||
a.NativeObject());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register predicate as recursive relation.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public void RegisterRelation(FuncDecl f) throws Z3Exception
|
||||
{
|
||||
|
||||
Context().CheckContextMatch(f);
|
||||
Native.fixedpointRegisterRelation(Context().nCtx(), NativeObject(),
|
||||
f.NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add rule into the fixedpoint solver.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public void AddRule(BoolExpr rule, Symbol name) throws Z3Exception
|
||||
{
|
||||
|
||||
Context().CheckContextMatch(rule);
|
||||
Native.fixedpointAddRule(Context().nCtx(), NativeObject(),
|
||||
rule.NativeObject(), AST.GetNativeObject(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add table fact to the fixedpoint solver.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public void AddFact(FuncDecl pred, int[] args) throws Z3Exception
|
||||
{
|
||||
|
||||
Context().CheckContextMatch(pred);
|
||||
Native.fixedpointAddFact(Context().nCtx(), NativeObject(),
|
||||
pred.NativeObject(), (int) args.length, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the fixedpoint solver. A query is a conjunction of constraints. The
|
||||
* constraints may include the recursively defined relations. The query is
|
||||
* satisfiable if there is an instance of the query variables and a
|
||||
* derivation for it. The query is unsatisfiable if there are no derivations
|
||||
* satisfying the query variables.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Status Query(BoolExpr query) throws Z3Exception
|
||||
{
|
||||
|
||||
Context().CheckContextMatch(query);
|
||||
Z3_lbool r = Z3_lbool.fromInt(Native.fixedpointQuery(Context().nCtx(),
|
||||
NativeObject(), query.NativeObject()));
|
||||
switch (r)
|
||||
{
|
||||
case Z3_L_TRUE:
|
||||
return Status.SATISFIABLE;
|
||||
case Z3_L_FALSE:
|
||||
return Status.UNSATISFIABLE;
|
||||
default:
|
||||
return Status.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the fixedpoint solver. A query is an array of relations. The query
|
||||
* is satisfiable if there is an instance of some relation that is
|
||||
* non-empty. The query is unsatisfiable if there are no derivations
|
||||
* satisfying any of the relations.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Status Query(FuncDecl[] relations) throws Z3Exception
|
||||
{
|
||||
|
||||
Context().CheckContextMatch(relations);
|
||||
Z3_lbool r = Z3_lbool.fromInt(Native.fixedpointQueryRelations(Context()
|
||||
.nCtx(), NativeObject(), AST.ArrayLength(relations), AST
|
||||
.ArrayToNative(relations)));
|
||||
switch (r)
|
||||
{
|
||||
case Z3_L_TRUE:
|
||||
return Status.SATISFIABLE;
|
||||
case Z3_L_FALSE:
|
||||
return Status.UNSATISFIABLE;
|
||||
default:
|
||||
return Status.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a backtracking point. <seealso cref="Pop"/>
|
||||
**/
|
||||
public void Push() throws Z3Exception
|
||||
{
|
||||
Native.fixedpointPush(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Backtrack one backtracking point. <remarks>Note that an exception is
|
||||
* thrown if Pop is called without a corresponding <code>Push</code>
|
||||
* </remarks> <seealso cref="Push"/>
|
||||
**/
|
||||
public void Pop() throws Z3Exception
|
||||
{
|
||||
Native.fixedpointPop(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Update named rule into in the fixedpoint solver.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public void UpdateRule(BoolExpr rule, Symbol name) throws Z3Exception
|
||||
{
|
||||
|
||||
Context().CheckContextMatch(rule);
|
||||
Native.fixedpointUpdateRule(Context().nCtx(), NativeObject(),
|
||||
rule.NativeObject(), AST.GetNativeObject(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve satisfying instance or instances of solver, or definitions for
|
||||
* the recursive predicates that show unsatisfiability.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Expr GetAnswer() throws Z3Exception
|
||||
{
|
||||
long ans = Native.fixedpointGetAnswer(Context().nCtx(), NativeObject());
|
||||
return (ans == 0) ? null : Expr.Create(Context(), ans);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve explanation why fixedpoint engine returned status Unknown.
|
||||
**/
|
||||
public String GetReasonUnknown() throws Z3Exception
|
||||
{
|
||||
|
||||
return Native.fixedpointGetReasonUnknown(Context().nCtx(),
|
||||
NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the number of levels explored for a given predicate.
|
||||
**/
|
||||
public int GetNumLevels(FuncDecl predicate) throws Z3Exception
|
||||
{
|
||||
return Native.fixedpointGetNumLevels(Context().nCtx(), NativeObject(),
|
||||
predicate.NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the cover of a predicate.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Expr GetCoverDelta(int level, FuncDecl predicate) throws Z3Exception
|
||||
{
|
||||
long res = Native.fixedpointGetCoverDelta(Context().nCtx(),
|
||||
NativeObject(), level, predicate.NativeObject());
|
||||
return (res == 0) ? null : Expr.Create(Context(), res);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add <tt>property</tt> about the <tt>predicate</tt>. The property is added
|
||||
* at <tt>level</tt>.
|
||||
**/
|
||||
public void AddCover(int level, FuncDecl predicate, Expr property)
|
||||
throws Z3Exception
|
||||
{
|
||||
Native.fixedpointAddCover(Context().nCtx(), NativeObject(), level,
|
||||
predicate.NativeObject(), property.NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve internal string representation of fixedpoint object.
|
||||
**/
|
||||
public String toString()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Native.fixedpointToString(Context().nCtx(), NativeObject(),
|
||||
0, null);
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
return "Z3Exception: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Instrument the Datalog engine on which table representation to use for
|
||||
* recursive predicate.
|
||||
**/
|
||||
public void SetPredicateRepresentation(FuncDecl f, Symbol[] kinds) throws Z3Exception
|
||||
{
|
||||
|
||||
Native.fixedpointSetPredicateRepresentation(Context().nCtx(),
|
||||
NativeObject(), f.NativeObject(), AST.ArrayLength(kinds),
|
||||
Symbol.ArrayToNative(kinds));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert benchmark given as set of axioms, rules and queries to a string.
|
||||
**/
|
||||
public String toString(BoolExpr[] queries) throws Z3Exception
|
||||
{
|
||||
|
||||
return Native.fixedpointToString(Context().nCtx(), NativeObject(),
|
||||
AST.ArrayLength(queries), AST.ArrayToNative(queries));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve set of rules added to fixedpoint context.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public BoolExpr[] Rules() throws Z3Exception
|
||||
{
|
||||
|
||||
ASTVector v = new ASTVector(Context(), Native.fixedpointGetRules(
|
||||
Context().nCtx(), NativeObject()));
|
||||
int n = v.Size();
|
||||
BoolExpr[] res = new BoolExpr[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = new BoolExpr(Context(), v.get(i).NativeObject());
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve set of assertions added to fixedpoint context.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public BoolExpr[] Assertions() throws Z3Exception
|
||||
{
|
||||
|
||||
ASTVector v = new ASTVector(Context(), Native.fixedpointGetAssertions(
|
||||
Context().nCtx(), NativeObject()));
|
||||
int n = v.Size();
|
||||
BoolExpr[] res = new BoolExpr[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = new BoolExpr(Context(), v.get(i).NativeObject());
|
||||
return res;
|
||||
}
|
||||
|
||||
Fixedpoint(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
Fixedpoint(Context ctx) throws Z3Exception
|
||||
{
|
||||
super(ctx, Native.mkFixedpoint(ctx.nCtx()));
|
||||
}
|
||||
|
||||
void IncRef(long o) throws Z3Exception
|
||||
{
|
||||
Context().Fixedpoint_DRQ().IncAndClear(Context(), o);
|
||||
super.IncRef(o);
|
||||
}
|
||||
|
||||
void DecRef(long o) throws Z3Exception
|
||||
{
|
||||
Context().Fixedpoint_DRQ().Add(o);
|
||||
super.DecRef(o);
|
||||
}
|
||||
}
|
31
src/api/java/FixedpointDecRefQueue.java
Normal file
31
src/api/java/FixedpointDecRefQueue.java
Normal file
|
@ -0,0 +1,31 @@
|
|||
/**
|
||||
* Copyright (c) 2012 Microsoft Corporation
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
class FixedpointDecRefQueue extends IDecRefQueue
|
||||
{
|
||||
public void IncRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Native.fixedpointIncRef(ctx.nCtx(), obj);
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
// OK.
|
||||
}
|
||||
}
|
||||
|
||||
public void DecRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Native.fixedpointDecRef(ctx.nCtx(), obj);
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
// OK.
|
||||
}
|
||||
}
|
||||
};
|
397
src/api/java/FuncDecl.java
Normal file
397
src/api/java/FuncDecl.java
Normal file
|
@ -0,0 +1,397 @@
|
|||
/**
|
||||
* This file was automatically generated from FuncDecl.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
import com.microsoft.z3.enumerations.*;
|
||||
|
||||
/**
|
||||
* Function declarations.
|
||||
**/
|
||||
public class FuncDecl extends AST
|
||||
{
|
||||
/**
|
||||
* Comparison operator.
|
||||
*
|
||||
* @return True if <paramref name="a"/> and <paramref name="b"/> share the
|
||||
* same context and are equal, false otherwise.
|
||||
**/
|
||||
/* Overloaded operators are not translated. */
|
||||
|
||||
/**
|
||||
* Comparison operator.
|
||||
*
|
||||
* @return True if <paramref name="a"/> and <paramref name="b"/> do not
|
||||
* share the same context or are not equal, false otherwise.
|
||||
**/
|
||||
/* Overloaded operators are not translated. */
|
||||
|
||||
/**
|
||||
* Object comparison.
|
||||
**/
|
||||
public boolean Equals(Object o)
|
||||
{
|
||||
FuncDecl casted = (FuncDecl) o;
|
||||
if (casted == null)
|
||||
return false;
|
||||
return this == casted;
|
||||
}
|
||||
|
||||
/**
|
||||
* A hash code.
|
||||
**/
|
||||
public int GetHashCode() throws Z3Exception
|
||||
{
|
||||
return super.GetHashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* A string representations of the function declaration.
|
||||
**/
|
||||
public String toString()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Native.funcDeclToString(Context().nCtx(), NativeObject());
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
return "Z3Exception: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a unique identifier for the function declaration.
|
||||
**/
|
||||
public int Id() throws Z3Exception
|
||||
{
|
||||
return Native.getFuncDeclId(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* The arity of the function declaration
|
||||
**/
|
||||
public int Arity() throws Z3Exception
|
||||
{
|
||||
return Native.getArity(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* The size of the domain of the function declaration <seealso
|
||||
* cref="Arity"/>
|
||||
**/
|
||||
public int DomainSize() throws Z3Exception
|
||||
{
|
||||
return Native.getDomainSize(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* The domain of the function declaration
|
||||
**/
|
||||
public Sort[] Domain() throws Z3Exception
|
||||
{
|
||||
|
||||
int n = DomainSize();
|
||||
|
||||
Sort[] res = new Sort[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = Sort.Create(Context(),
|
||||
Native.getDomain(Context().nCtx(), NativeObject(), i));
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* The range of the function declaration
|
||||
**/
|
||||
public Sort Range() throws Z3Exception
|
||||
{
|
||||
|
||||
return Sort.Create(Context(),
|
||||
Native.getRange(Context().nCtx(), NativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* The kind of the function declaration.
|
||||
**/
|
||||
public Z3_decl_kind DeclKind() throws Z3Exception
|
||||
{
|
||||
return Z3_decl_kind.fromInt(Native.getDeclKind(Context().nCtx(),
|
||||
NativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the function declaration
|
||||
**/
|
||||
public Symbol Name() throws Z3Exception
|
||||
{
|
||||
|
||||
return Symbol.Create(Context(),
|
||||
Native.getDeclName(Context().nCtx(), NativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of parameters of the function declaration
|
||||
**/
|
||||
public int NumParameters() throws Z3Exception
|
||||
{
|
||||
return Native.getDeclNumParameters(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* The parameters of the function declaration
|
||||
**/
|
||||
public Parameter[] Parameters() throws Z3Exception
|
||||
{
|
||||
|
||||
int num = NumParameters();
|
||||
Parameter[] res = new Parameter[num];
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
Z3_parameter_kind k = Z3_parameter_kind.fromInt(Native
|
||||
.getDeclParameterKind(Context().nCtx(), NativeObject(), i));
|
||||
switch (k)
|
||||
{
|
||||
case Z3_PARAMETER_INT:
|
||||
res[i] = new Parameter(k, Native.getDeclIntParameter(Context()
|
||||
.nCtx(), NativeObject(), i));
|
||||
break;
|
||||
case Z3_PARAMETER_DOUBLE:
|
||||
res[i] = new Parameter(k, Native.getDeclDoubleParameter(
|
||||
Context().nCtx(), NativeObject(), i));
|
||||
break;
|
||||
case Z3_PARAMETER_SYMBOL:
|
||||
res[i] = new Parameter(k, Symbol.Create(Context(), Native
|
||||
.getDeclSymbolParameter(Context().nCtx(),
|
||||
NativeObject(), i)));
|
||||
break;
|
||||
case Z3_PARAMETER_SORT:
|
||||
res[i] = new Parameter(k, Sort.Create(Context(), Native
|
||||
.getDeclSortParameter(Context().nCtx(), NativeObject(),
|
||||
i)));
|
||||
break;
|
||||
case Z3_PARAMETER_AST:
|
||||
res[i] = new Parameter(k, new AST(Context(),
|
||||
Native.getDeclAstParameter(Context().nCtx(),
|
||||
NativeObject(), i)));
|
||||
break;
|
||||
case Z3_PARAMETER_FUNC_DECL:
|
||||
res[i] = new Parameter(k, new FuncDecl(Context(),
|
||||
Native.getDeclFuncDeclParameter(Context().nCtx(),
|
||||
NativeObject(), i)));
|
||||
break;
|
||||
case Z3_PARAMETER_RATIONAL:
|
||||
res[i] = new Parameter(k, Native.getDeclRationalParameter(
|
||||
Context().nCtx(), NativeObject(), i));
|
||||
break;
|
||||
default:
|
||||
throw new Z3Exception(
|
||||
"Unknown function declaration parameter kind encountered");
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function declarations can have Parameters associated with them.
|
||||
**/
|
||||
public class Parameter
|
||||
{
|
||||
private Z3_parameter_kind kind;
|
||||
private int i;
|
||||
private double d;
|
||||
private Symbol sym;
|
||||
private Sort srt;
|
||||
private AST ast;
|
||||
private FuncDecl fd;
|
||||
private String r;
|
||||
|
||||
/**
|
||||
* The int value of the parameter.</summary>
|
||||
**/
|
||||
public int Int() throws Z3Exception
|
||||
{
|
||||
if (ParameterKind() != Z3_parameter_kind.Z3_PARAMETER_INT)
|
||||
throw new Z3Exception("parameter is not an int");
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
* The double value of the parameter.</summary>
|
||||
**/
|
||||
public double Double() throws Z3Exception
|
||||
{
|
||||
if (ParameterKind() != Z3_parameter_kind.Z3_PARAMETER_DOUBLE)
|
||||
throw new Z3Exception("parameter is not a double ");
|
||||
return d;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Symbol value of the parameter.</summary>
|
||||
**/
|
||||
public Symbol Symbol() throws Z3Exception
|
||||
{
|
||||
if (ParameterKind() != Z3_parameter_kind.Z3_PARAMETER_SYMBOL)
|
||||
throw new Z3Exception("parameter is not a Symbol");
|
||||
return sym;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Sort value of the parameter.</summary>
|
||||
**/
|
||||
public Sort Sort() throws Z3Exception
|
||||
{
|
||||
if (ParameterKind() != Z3_parameter_kind.Z3_PARAMETER_SORT)
|
||||
throw new Z3Exception("parameter is not a Sort");
|
||||
return srt;
|
||||
}
|
||||
|
||||
/**
|
||||
* The AST value of the parameter.</summary>
|
||||
**/
|
||||
public AST AST() throws Z3Exception
|
||||
{
|
||||
if (ParameterKind() != Z3_parameter_kind.Z3_PARAMETER_AST)
|
||||
throw new Z3Exception("parameter is not an AST");
|
||||
return ast;
|
||||
}
|
||||
|
||||
/**
|
||||
* The FunctionDeclaration value of the parameter.</summary>
|
||||
**/
|
||||
public FuncDecl FuncDecl() throws Z3Exception
|
||||
{
|
||||
if (ParameterKind() != Z3_parameter_kind.Z3_PARAMETER_FUNC_DECL)
|
||||
throw new Z3Exception("parameter is not a function declaration");
|
||||
return fd;
|
||||
}
|
||||
|
||||
/**
|
||||
* The rational string value of the parameter.</summary>
|
||||
**/
|
||||
public String Rational() throws Z3Exception
|
||||
{
|
||||
if (ParameterKind() != Z3_parameter_kind.Z3_PARAMETER_RATIONAL)
|
||||
throw new Z3Exception("parameter is not a rational String");
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* The kind of the parameter.
|
||||
**/
|
||||
public Z3_parameter_kind ParameterKind() throws Z3Exception
|
||||
{
|
||||
return kind;
|
||||
}
|
||||
|
||||
Parameter(Z3_parameter_kind k, int i)
|
||||
{
|
||||
this.kind = k;
|
||||
this.i = i;
|
||||
}
|
||||
|
||||
Parameter(Z3_parameter_kind k, double d)
|
||||
{
|
||||
this.kind = k;
|
||||
this.d = d;
|
||||
}
|
||||
|
||||
Parameter(Z3_parameter_kind k, Symbol s)
|
||||
{
|
||||
this.kind = k;
|
||||
this.sym = s;
|
||||
}
|
||||
|
||||
Parameter(Z3_parameter_kind k, Sort s)
|
||||
{
|
||||
this.kind = k;
|
||||
this.srt = s;
|
||||
}
|
||||
|
||||
Parameter(Z3_parameter_kind k, AST a)
|
||||
{
|
||||
this.kind = k;
|
||||
this.ast = a;
|
||||
}
|
||||
|
||||
Parameter(Z3_parameter_kind k, FuncDecl fd)
|
||||
{
|
||||
this.kind = k;
|
||||
this.fd = fd;
|
||||
}
|
||||
|
||||
Parameter(Z3_parameter_kind k, String r)
|
||||
{
|
||||
this.kind = k;
|
||||
this.r = r;
|
||||
}
|
||||
}
|
||||
|
||||
FuncDecl(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
|
||||
}
|
||||
|
||||
FuncDecl(Context ctx, Symbol name, Sort[] domain, Sort range)
|
||||
throws Z3Exception
|
||||
{
|
||||
super(ctx, Native.mkFuncDecl(ctx.nCtx(), name.NativeObject(),
|
||||
AST.ArrayLength(domain), AST.ArrayToNative(domain),
|
||||
range.NativeObject()));
|
||||
|
||||
}
|
||||
|
||||
FuncDecl(Context ctx, String prefix, Sort[] domain, Sort range)
|
||||
throws Z3Exception
|
||||
{
|
||||
super(ctx, Native.mkFreshFuncDecl(ctx.nCtx(), prefix,
|
||||
AST.ArrayLength(domain), AST.ArrayToNative(domain),
|
||||
range.NativeObject()));
|
||||
|
||||
}
|
||||
|
||||
void CheckNativeObject(long obj) throws Z3Exception
|
||||
{
|
||||
if (Native.getAstKind(Context().nCtx(), obj) != Z3_ast_kind.Z3_FUNC_DECL_AST
|
||||
.toInt())
|
||||
throw new Z3Exception(
|
||||
"Underlying object is not a function declaration");
|
||||
super.CheckNativeObject(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create expression that applies function to arguments. <param
|
||||
* name="args"></param>
|
||||
*
|
||||
* @return
|
||||
**/
|
||||
/* operator this[] not translated */
|
||||
|
||||
/**
|
||||
* Create expression that applies function to arguments. <param
|
||||
* name="args"></param>
|
||||
*
|
||||
* @return
|
||||
**/
|
||||
public Expr Apply(Expr[] args) throws Z3Exception
|
||||
{
|
||||
Context().CheckContextMatch(args);
|
||||
return Expr.Create(Context(), this, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create expression that applies function to one argument. <param
|
||||
* name="arg"></param>
|
||||
*
|
||||
* @return
|
||||
**/
|
||||
public Expr Apply(Expr arg) throws Z3Exception
|
||||
{
|
||||
Context().CheckContextMatch(arg);
|
||||
Expr[] a = { arg };
|
||||
return Expr.Create(Context(), this, a);
|
||||
}
|
||||
|
||||
}
|
185
src/api/java/FuncInterp.java
Normal file
185
src/api/java/FuncInterp.java
Normal file
|
@ -0,0 +1,185 @@
|
|||
/**
|
||||
* This file was automatically generated from FuncInterp.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* A function interpretation is represented as a finite map and an 'else' value.
|
||||
* Each entry in the finite map represents the value of a function given a set
|
||||
* of arguments.
|
||||
**/
|
||||
public class FuncInterp extends Z3Object
|
||||
{
|
||||
/**
|
||||
* An Entry object represents an element in the finite map used to encode a
|
||||
* function interpretation.
|
||||
**/
|
||||
public class Entry extends Z3Object
|
||||
{
|
||||
/**
|
||||
* Return the (symbolic) value of this entry.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Expr Value() throws Z3Exception
|
||||
{
|
||||
return Expr.Create(Context(),
|
||||
Native.funcEntryGetValue(Context().nCtx(), NativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of arguments of the entry.
|
||||
**/
|
||||
public int NumArgs() throws Z3Exception
|
||||
{
|
||||
return Native.funcEntryGetNumArgs(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* The arguments of the function entry.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Expr[] Args() throws Z3Exception
|
||||
{
|
||||
int n = NumArgs();
|
||||
Expr[] res = new Expr[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = Expr.Create(Context(), Native.funcEntryGetArg(
|
||||
Context().nCtx(), NativeObject(), i));
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* A string representation of the function entry.
|
||||
**/
|
||||
public String toString()
|
||||
{
|
||||
try
|
||||
{
|
||||
int n = NumArgs();
|
||||
String res = "[";
|
||||
Expr[] args = Args();
|
||||
for (int i = 0; i < n; i++)
|
||||
res += args[i] + ", ";
|
||||
return res + Value() + "]";
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
return new String("Z3Exception: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
Entry(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
void IncRef(long o) throws Z3Exception
|
||||
{
|
||||
Context().FuncEntry_DRQ().IncAndClear(Context(), o);
|
||||
super.IncRef(o);
|
||||
}
|
||||
|
||||
void DecRef(long o) throws Z3Exception
|
||||
{
|
||||
Context().FuncEntry_DRQ().Add(o);
|
||||
super.DecRef(o);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The number of entries in the function interpretation.
|
||||
**/
|
||||
public int NumEntries() throws Z3Exception
|
||||
{
|
||||
return Native.funcInterpGetNumEntries(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* The entries in the function interpretation
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Entry[] Entries() throws Z3Exception
|
||||
{
|
||||
int n = NumEntries();
|
||||
Entry[] res = new Entry[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = new Entry(Context(), Native.funcInterpGetEntry(Context()
|
||||
.nCtx(), NativeObject(), i));
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* The (symbolic) `else' value of the function interpretation.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Expr Else() throws Z3Exception
|
||||
{
|
||||
return Expr.Create(Context(),
|
||||
Native.funcInterpGetElse(Context().nCtx(), NativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* The arity of the function interpretation
|
||||
**/
|
||||
public int Arity() throws Z3Exception
|
||||
{
|
||||
return Native.funcInterpGetArity(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* A string representation of the function interpretation.
|
||||
**/
|
||||
public String toString()
|
||||
{
|
||||
try
|
||||
{
|
||||
String res = "";
|
||||
res += "[";
|
||||
for (Entry e : Entries())
|
||||
{
|
||||
int n = e.NumArgs();
|
||||
if (n > 1)
|
||||
res += "[";
|
||||
Expr[] args = e.Args();
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
if (i != 0)
|
||||
res += ", ";
|
||||
res += args[i];
|
||||
}
|
||||
if (n > 1)
|
||||
res += "]";
|
||||
res += " -> " + e.Value() + ", ";
|
||||
}
|
||||
res += "else -> " + Else();
|
||||
res += "]";
|
||||
return res;
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
return new String("Z3Exception: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
FuncInterp(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
void IncRef(long o) throws Z3Exception
|
||||
{
|
||||
Context().FuncInterp_DRQ().IncAndClear(Context(), o);
|
||||
super.IncRef(o);
|
||||
}
|
||||
|
||||
void DecRef(long o) throws Z3Exception
|
||||
{
|
||||
Context().FuncInterp_DRQ().Add(o);
|
||||
super.DecRef(o);
|
||||
}
|
||||
}
|
31
src/api/java/FuncInterpDecRefQueue.java
Normal file
31
src/api/java/FuncInterpDecRefQueue.java
Normal file
|
@ -0,0 +1,31 @@
|
|||
/**
|
||||
* Copyright (c) 2012 Microsoft Corporation
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
class FuncInterpDecRefQueue extends IDecRefQueue
|
||||
{
|
||||
public void IncRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Native.funcInterpIncRef(ctx.nCtx(), obj);
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
// OK.
|
||||
}
|
||||
}
|
||||
|
||||
public void DecRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Native.funcInterpDecRef(ctx.nCtx(), obj);
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
// OK.
|
||||
}
|
||||
}
|
||||
};
|
31
src/api/java/FuncInterpEntryDecRefQueue.java
Normal file
31
src/api/java/FuncInterpEntryDecRefQueue.java
Normal file
|
@ -0,0 +1,31 @@
|
|||
/**
|
||||
* Copyright (c) 2012 Microsoft Corporation
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
class FuncInterpEntryDecRefQueue extends IDecRefQueue
|
||||
{
|
||||
public void IncRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Native.funcEntryIncRef(ctx.nCtx(), obj);
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
// OK.
|
||||
}
|
||||
}
|
||||
|
||||
public void DecRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Native.funcEntryDecRef(ctx.nCtx(), obj);
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
// OK.
|
||||
}
|
||||
}
|
||||
};
|
231
src/api/java/Goal.java
Normal file
231
src/api/java/Goal.java
Normal file
|
@ -0,0 +1,231 @@
|
|||
/**
|
||||
* This file was automatically generated from Goal.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
import com.microsoft.z3.enumerations.*;
|
||||
|
||||
/**
|
||||
* A goal (aka problem). A goal is essentially a set of formulas, that can be
|
||||
* solved and/or transformed using tactics and solvers.
|
||||
**/
|
||||
public class Goal extends Z3Object
|
||||
{
|
||||
/**
|
||||
* The precision of the goal. <remarks> Goals can be transformed using over
|
||||
* and under approximations. An under approximation is applied when the
|
||||
* objective is to find a model for a given goal. An over approximation is
|
||||
* applied when the objective is to find a proof for a given goal.
|
||||
* </remarks>
|
||||
**/
|
||||
public Z3_goal_prec Precision() throws Z3Exception
|
||||
{
|
||||
return Z3_goal_prec.fromInt(Native.goalPrecision(Context().nCtx(),
|
||||
NativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the goal is precise.
|
||||
**/
|
||||
public boolean IsPrecise() throws Z3Exception
|
||||
{
|
||||
return Precision() == Z3_goal_prec.Z3_GOAL_PRECISE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the goal is an under-approximation.
|
||||
**/
|
||||
public boolean IsUnderApproximation() throws Z3Exception
|
||||
{
|
||||
return Precision() == Z3_goal_prec.Z3_GOAL_UNDER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the goal is an over-approximation.
|
||||
**/
|
||||
public boolean IsOverApproximation() throws Z3Exception
|
||||
{
|
||||
return Precision() == Z3_goal_prec.Z3_GOAL_OVER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the goal is garbage (i.e., the product of over- and
|
||||
* under-approximations).
|
||||
**/
|
||||
public boolean IsGarbage() throws Z3Exception
|
||||
{
|
||||
return Precision() == Z3_goal_prec.Z3_GOAL_UNDER_OVER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the <paramref name="constraints"/> to the given goal.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public void Assert(BoolExpr[] constraints) throws Z3Exception
|
||||
{
|
||||
Context().CheckContextMatch(constraints);
|
||||
for (BoolExpr c : constraints)
|
||||
{
|
||||
Native.goalAssert(Context().nCtx(), NativeObject(),
|
||||
c.NativeObject());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a <paramref name="constraint"/> to the given goal.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public void Assert(BoolExpr constraint) throws Z3Exception
|
||||
{
|
||||
Context().CheckContextMatch(constraint);
|
||||
Native.goalAssert(Context().nCtx(), NativeObject(),
|
||||
constraint.NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the goal contains `false'.
|
||||
**/
|
||||
public boolean Inconsistent() throws Z3Exception
|
||||
{
|
||||
return Native.goalInconsistent(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* The depth of the goal. <remarks> This tracks how many transformations
|
||||
* were applied to it. </remarks>
|
||||
**/
|
||||
public int Depth() throws Z3Exception
|
||||
{
|
||||
return Native.goalDepth(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Erases all formulas from the given goal.
|
||||
**/
|
||||
public void Reset() throws Z3Exception
|
||||
{
|
||||
Native.goalReset(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of formulas in the goal.
|
||||
**/
|
||||
public int Size() throws Z3Exception
|
||||
{
|
||||
return Native.goalSize(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* The formulas in the goal.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public BoolExpr[] Formulas() throws Z3Exception
|
||||
{
|
||||
int n = Size();
|
||||
BoolExpr[] res = new BoolExpr[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = new BoolExpr(Context(), Native.goalFormula(Context()
|
||||
.nCtx(), NativeObject(), i));
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of formulas, subformulas and terms in the goal.
|
||||
**/
|
||||
public int NumExprs() throws Z3Exception
|
||||
{
|
||||
return Native.goalNumExprs(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the goal is empty, and it is precise or the product of
|
||||
* an under approximation.
|
||||
**/
|
||||
public boolean IsDecidedSat() throws Z3Exception
|
||||
{
|
||||
return Native.goalIsDecidedSat(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the goal contains `false', and it is precise or the
|
||||
* product of an over approximation.
|
||||
**/
|
||||
public boolean IsDecidedUnsat() throws Z3Exception
|
||||
{
|
||||
return Native.goalIsDecidedUnsat(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates (copies) the Goal to the target Context <paramref
|
||||
* name="ctx"/>.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Goal Translate(Context ctx) throws Z3Exception
|
||||
{
|
||||
return new Goal(ctx, Native.goalTranslate(Context().nCtx(),
|
||||
NativeObject(), ctx.nCtx()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Simplifies the goal. <remarks>Essentially invokes the `simplify' tactic
|
||||
* on the goal.</remarks>
|
||||
**/
|
||||
public Goal Simplify(Params p) throws Z3Exception
|
||||
{
|
||||
Tactic t = Context().MkTactic("simplify");
|
||||
ApplyResult res = t.Apply(this, p);
|
||||
|
||||
if (res.NumSubgoals() == 0)
|
||||
throw new Z3Exception("No subgoals");
|
||||
else
|
||||
return res.Subgoals()[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Goal to string conversion.
|
||||
*
|
||||
* @return A string representation of the Goal.
|
||||
**/
|
||||
public String toString()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Native.goalToString(Context().nCtx(), NativeObject());
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
return "Z3Exception: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
Goal(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
Goal(Context ctx, boolean models, boolean unsatCores, boolean proofs)
|
||||
throws Z3Exception
|
||||
{
|
||||
super(ctx, Native.mkGoal(ctx.nCtx(), (models) ? true : false,
|
||||
(unsatCores) ? true : false, (proofs) ? true : false));
|
||||
}
|
||||
|
||||
void IncRef(long o) throws Z3Exception
|
||||
{
|
||||
Context().Goal_DRQ().IncAndClear(Context(), o);
|
||||
super.IncRef(o);
|
||||
}
|
||||
|
||||
void DecRef(long o) throws Z3Exception
|
||||
{
|
||||
Context().Goal_DRQ().Add(o);
|
||||
super.DecRef(o);
|
||||
}
|
||||
|
||||
}
|
31
src/api/java/GoalDecRefQueue.java
Normal file
31
src/api/java/GoalDecRefQueue.java
Normal file
|
@ -0,0 +1,31 @@
|
|||
/**
|
||||
* Copyright (c) 2012 Microsoft Corporation
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
class GoalDecRefQueue extends IDecRefQueue
|
||||
{
|
||||
public void IncRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Native.goalIncRef(ctx.nCtx(), obj);
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
// OK.
|
||||
}
|
||||
}
|
||||
|
||||
public void DecRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Native.goalDecRef(ctx.nCtx(), obj);
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
// OK.
|
||||
}
|
||||
}
|
||||
};
|
48
src/api/java/IDecRefQueue.java
Normal file
48
src/api/java/IDecRefQueue.java
Normal file
|
@ -0,0 +1,48 @@
|
|||
/**
|
||||
* This file was automatically generated from IDecRefQueue.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
abstract class IDecRefQueue
|
||||
{
|
||||
protected Object m_lock = new Object();
|
||||
protected LinkedList<Long> m_queue = new LinkedList<Long>();
|
||||
final int m_move_limit = 1024;
|
||||
|
||||
public abstract void IncRef(Context ctx, long obj);
|
||||
|
||||
public abstract void DecRef(Context ctx, long obj);
|
||||
|
||||
public void IncAndClear(Context ctx, long o)
|
||||
{
|
||||
IncRef(ctx, o);
|
||||
if (m_queue.size() >= m_move_limit)
|
||||
Clear(ctx);
|
||||
}
|
||||
|
||||
public void Add(long o)
|
||||
{
|
||||
if (o == 0)
|
||||
return;
|
||||
|
||||
synchronized (m_lock)
|
||||
{
|
||||
m_queue.add(o);
|
||||
}
|
||||
}
|
||||
|
||||
public void Clear(Context ctx)
|
||||
{
|
||||
synchronized (m_lock)
|
||||
{
|
||||
for (Long o : m_queue)
|
||||
DecRef(ctx, o);
|
||||
m_queue.clear();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,9 +17,11 @@ Notes:
|
|||
|
||||
--*/
|
||||
|
||||
package com.Microsoft.Z3;
|
||||
package com.microsoft.z3;
|
||||
|
||||
public class IDisposable
|
||||
{
|
||||
public void Dispose() {}
|
||||
public void Dispose() throws Z3Exception
|
||||
{
|
||||
}
|
||||
}
|
26
src/api/java/IntExpr.java
Normal file
26
src/api/java/IntExpr.java
Normal file
|
@ -0,0 +1,26 @@
|
|||
/**
|
||||
* This file was automatically generated from IntExpr.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* Int expressions
|
||||
**/
|
||||
public class IntExpr extends ArithExpr
|
||||
{
|
||||
/**
|
||||
* Constructor for IntExpr </summary>
|
||||
**/
|
||||
protected IntExpr(Context ctx) throws Z3Exception
|
||||
{
|
||||
super(ctx);
|
||||
}
|
||||
|
||||
IntExpr(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
}
|
65
src/api/java/IntNum.java
Normal file
65
src/api/java/IntNum.java
Normal file
|
@ -0,0 +1,65 @@
|
|||
/**
|
||||
* This file was automatically generated from IntNum.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
/**
|
||||
* Integer Numerals
|
||||
**/
|
||||
public class IntNum extends IntExpr
|
||||
{
|
||||
|
||||
IntNum(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the int value.
|
||||
**/
|
||||
public int Int() throws Z3Exception
|
||||
{
|
||||
Native.IntPtr res = new Native.IntPtr();
|
||||
if (Native.getNumeralInt(Context().nCtx(), NativeObject(), res) ^ true)
|
||||
throw new Z3Exception("Numeral is not an int");
|
||||
return res.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the 64-bit int value.
|
||||
**/
|
||||
public long Int64() throws Z3Exception
|
||||
{
|
||||
Native.LongPtr res = new Native.LongPtr();
|
||||
if (Native.getNumeralInt64(Context().nCtx(), NativeObject(), res) ^ true)
|
||||
throw new Z3Exception("Numeral is not an int64");
|
||||
return res.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the BigInteger value.
|
||||
**/
|
||||
public BigInteger BigInteger() throws Z3Exception
|
||||
{
|
||||
return new BigInteger(this.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the numeral.
|
||||
**/
|
||||
public String toString()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Native.getNumeralString(Context().nCtx(), NativeObject());
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
return "Z3Exception: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
}
|
23
src/api/java/IntSort.java
Normal file
23
src/api/java/IntSort.java
Normal file
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* This file was automatically generated from IntSort.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* An Integer sort
|
||||
**/
|
||||
public class IntSort extends ArithSort
|
||||
{
|
||||
IntSort(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
IntSort(Context ctx) throws Z3Exception
|
||||
{
|
||||
super(ctx, Native.mkIntSort(ctx.nCtx()));
|
||||
}
|
||||
}
|
44
src/api/java/IntSymbol.java
Normal file
44
src/api/java/IntSymbol.java
Normal file
|
@ -0,0 +1,44 @@
|
|||
/**
|
||||
* This file was automatically generated from IntSymbol.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
import com.microsoft.z3.enumerations.*;
|
||||
|
||||
/**
|
||||
* Numbered symbols
|
||||
**/
|
||||
public class IntSymbol extends Symbol
|
||||
{
|
||||
/**
|
||||
* The int value of the symbol. <remarks>Throws an exception if the symbol
|
||||
* is not of int kind. </remarks>
|
||||
**/
|
||||
public int Int() throws Z3Exception
|
||||
{
|
||||
if (!IsIntSymbol())
|
||||
throw new Z3Exception("Int requested from non-Int symbol");
|
||||
return Native.getSymbolInt(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
IntSymbol(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
IntSymbol(Context ctx, int i) throws Z3Exception
|
||||
{
|
||||
super(ctx, Native.mkIntSymbol(ctx.nCtx(), i));
|
||||
}
|
||||
|
||||
void CheckNativeObject(long obj) throws Z3Exception
|
||||
{
|
||||
if (Native.getSymbolKind(Context().nCtx(), obj) != Z3_symbol_kind.Z3_INT_SYMBOL
|
||||
.toInt())
|
||||
throw new Z3Exception("Symbol is not of integer kind");
|
||||
super.CheckNativeObject(obj);
|
||||
}
|
||||
}
|
101
src/api/java/ListSort.java
Normal file
101
src/api/java/ListSort.java
Normal file
|
@ -0,0 +1,101 @@
|
|||
/**
|
||||
* This file was automatically generated from ListSort.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* List sorts.
|
||||
**/
|
||||
public class ListSort extends Sort
|
||||
{
|
||||
/**
|
||||
* The declaration of the nil function of this list sort.
|
||||
**/
|
||||
public FuncDecl NilDecl()
|
||||
{
|
||||
|
||||
return nilDecl;
|
||||
}
|
||||
|
||||
/**
|
||||
* The empty list.
|
||||
**/
|
||||
public Expr Nil()
|
||||
{
|
||||
|
||||
return nilConst;
|
||||
}
|
||||
|
||||
/**
|
||||
* The declaration of the isNil function of this list sort.
|
||||
**/
|
||||
public FuncDecl IsNilDecl()
|
||||
{
|
||||
|
||||
return isNilDecl;
|
||||
}
|
||||
|
||||
/**
|
||||
* The declaration of the cons function of this list sort.
|
||||
**/
|
||||
public FuncDecl ConsDecl()
|
||||
{
|
||||
|
||||
return consDecl;
|
||||
}
|
||||
|
||||
/**
|
||||
* The declaration of the isCons function of this list sort.
|
||||
*
|
||||
**/
|
||||
public FuncDecl IsConsDecl()
|
||||
{
|
||||
|
||||
return isConsDecl;
|
||||
}
|
||||
|
||||
/**
|
||||
* The declaration of the head function of this list sort.
|
||||
**/
|
||||
public FuncDecl HeadDecl()
|
||||
{
|
||||
|
||||
return headDecl;
|
||||
}
|
||||
|
||||
/**
|
||||
* The declaration of the tail function of this list sort.
|
||||
**/
|
||||
public FuncDecl TailDecl()
|
||||
{
|
||||
|
||||
return tailDecl;
|
||||
}
|
||||
|
||||
private FuncDecl nilDecl, isNilDecl, consDecl, isConsDecl, headDecl,
|
||||
tailDecl;
|
||||
private Expr nilConst;
|
||||
|
||||
ListSort(Context ctx, Symbol name, Sort elemSort) throws Z3Exception
|
||||
{
|
||||
super(ctx);
|
||||
|
||||
Native.LongPtr inil = new Native.LongPtr(), iisnil = new Native.LongPtr();
|
||||
Native.LongPtr icons = new Native.LongPtr(), iiscons = new Native.LongPtr();
|
||||
Native.LongPtr ihead = new Native.LongPtr(), itail = new Native.LongPtr();
|
||||
|
||||
setNativeObject(Native.mkListSort(ctx.nCtx(), name.NativeObject(),
|
||||
elemSort.NativeObject(), inil, iisnil, icons, iiscons, ihead,
|
||||
itail));
|
||||
nilDecl = new FuncDecl(ctx, inil.value);
|
||||
isNilDecl = new FuncDecl(ctx, iisnil.value);
|
||||
consDecl = new FuncDecl(ctx, icons.value);
|
||||
isConsDecl = new FuncDecl(ctx, iiscons.value);
|
||||
headDecl = new FuncDecl(ctx, ihead.value);
|
||||
tailDecl = new FuncDecl(ctx, itail.value);
|
||||
nilConst = ctx.MkConst(nilDecl);
|
||||
}
|
||||
};
|
60
src/api/java/Log.java
Normal file
60
src/api/java/Log.java
Normal file
|
@ -0,0 +1,60 @@
|
|||
/**
|
||||
* This file was automatically generated from Log.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* Interaction logging for Z3. <remarks> Note that this is a global, static log
|
||||
* and if multiple Context objects are created, it logs the interaction with all
|
||||
* of them. </remarks>
|
||||
**/
|
||||
public final class Log
|
||||
{
|
||||
private static boolean m_is_open = false;
|
||||
|
||||
/**
|
||||
* Open an interaction log file. <param name="filename">the name of the file
|
||||
* to open</param>
|
||||
*
|
||||
* @return True if opening the log file succeeds, false otherwise.
|
||||
**/
|
||||
public static boolean Open(String filename)
|
||||
{
|
||||
m_is_open = true;
|
||||
return Native.openLog(filename) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the interaction log.
|
||||
**/
|
||||
public static void Close()
|
||||
{
|
||||
m_is_open = false;
|
||||
Native.closeLog();
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends the user-provided string <paramref name="s"/> to the interaction
|
||||
* log.
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public static void Append(String s) throws Z3Exception
|
||||
{
|
||||
if (!m_is_open)
|
||||
throw new Z3Exception("Log cannot be closed.");
|
||||
Native.appendLog(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the interaction log is opened.
|
||||
*
|
||||
* @return True if the interaction log is open, false otherwise.
|
||||
**/
|
||||
public static boolean isOpen()
|
||||
{
|
||||
return m_is_open;
|
||||
}
|
||||
}
|
302
src/api/java/Model.java
Normal file
302
src/api/java/Model.java
Normal file
|
@ -0,0 +1,302 @@
|
|||
/**
|
||||
* This file was automatically generated from Model.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
import com.microsoft.z3.enumerations.*;
|
||||
|
||||
/**
|
||||
* A Model contains interpretations (assignments) of constants and functions.
|
||||
**/
|
||||
public class Model extends Z3Object
|
||||
{
|
||||
/**
|
||||
* Retrieves the interpretation (the assignment) of <paramref name="a"/> in
|
||||
* the model. <param name="a">A Constant</param>
|
||||
*
|
||||
* @return An expression if the constant has an interpretation in the model,
|
||||
* null otherwise.
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Expr ConstInterp(Expr a) throws Z3Exception
|
||||
{
|
||||
Context().CheckContextMatch(a);
|
||||
return ConstInterp(a.FuncDecl());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the interpretation (the assignment) of <paramref name="f"/> in
|
||||
* the model. <param name="f">A function declaration of zero arity</param>
|
||||
*
|
||||
* @return An expression if the function has an interpretation in the model,
|
||||
* null otherwise.
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Expr ConstInterp(FuncDecl f) throws Z3Exception
|
||||
{
|
||||
Context().CheckContextMatch(f);
|
||||
if (f.Arity() != 0
|
||||
|| Native.getSortKind(Context().nCtx(),
|
||||
Native.getRange(Context().nCtx(), f.NativeObject())) == Z3_sort_kind.Z3_ARRAY_SORT
|
||||
.toInt())
|
||||
throw new Z3Exception(
|
||||
"Non-zero arity functions and arrays have FunctionInterpretations as a model. Use FuncInterp.");
|
||||
|
||||
long n = Native.modelGetConstInterp(Context().nCtx(), NativeObject(),
|
||||
f.NativeObject());
|
||||
if (n == 0)
|
||||
return null;
|
||||
else
|
||||
return Expr.Create(Context(), n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the interpretation (the assignment) of a non-constant <paramref
|
||||
* name="f"/> in the model. <param name="f">A function declaration of
|
||||
* non-zero arity</param>
|
||||
*
|
||||
* @return A FunctionInterpretation if the function has an interpretation in
|
||||
* the model, null otherwise.
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public FuncInterp FuncInterp(FuncDecl f) throws Z3Exception
|
||||
{
|
||||
Context().CheckContextMatch(f);
|
||||
|
||||
Z3_sort_kind sk = Z3_sort_kind.fromInt(Native.getSortKind(Context()
|
||||
.nCtx(), Native.getRange(Context().nCtx(), f.NativeObject())));
|
||||
|
||||
if (f.Arity() == 0)
|
||||
{
|
||||
long n = Native.modelGetConstInterp(Context().nCtx(),
|
||||
NativeObject(), f.NativeObject());
|
||||
|
||||
if (sk == Z3_sort_kind.Z3_ARRAY_SORT)
|
||||
{
|
||||
if (n == 0)
|
||||
return null;
|
||||
else
|
||||
{
|
||||
if (Native.isAsArray(Context().nCtx(), n) ^ true)
|
||||
throw new Z3Exception(
|
||||
"Argument was not an array constant");
|
||||
long fd = Native.getAsArrayFuncDecl(Context().nCtx(), n);
|
||||
return FuncInterp(new FuncDecl(Context(), fd));
|
||||
}
|
||||
} else
|
||||
{
|
||||
throw new Z3Exception(
|
||||
"Constant functions do not have a function interpretation; use ConstInterp");
|
||||
}
|
||||
} else
|
||||
{
|
||||
long n = Native.modelGetFuncInterp(Context().nCtx(),
|
||||
NativeObject(), f.NativeObject());
|
||||
if (n == 0)
|
||||
return null;
|
||||
else
|
||||
return new FuncInterp(Context(), n);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of constants that have an interpretation in the model.
|
||||
**/
|
||||
public int NumConsts() throws Z3Exception
|
||||
{
|
||||
return Native.modelGetNumConsts(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* The function declarations of the constants in the model.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public FuncDecl[] ConstDecls() throws Z3Exception
|
||||
{
|
||||
int n = NumConsts();
|
||||
FuncDecl[] res = new FuncDecl[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = new FuncDecl(Context(), Native.modelGetConstDecl(Context()
|
||||
.nCtx(), NativeObject(), i));
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of function interpretations in the model.
|
||||
**/
|
||||
public int NumFuncs() throws Z3Exception
|
||||
{
|
||||
return Native.modelGetNumFuncs(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* The function declarations of the function interpretations in the model.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public FuncDecl[] FuncDecls() throws Z3Exception
|
||||
{
|
||||
int n = NumFuncs();
|
||||
FuncDecl[] res = new FuncDecl[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = new FuncDecl(Context(), Native.modelGetFuncDecl(Context()
|
||||
.nCtx(), NativeObject(), i));
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* All symbols that have an interpretation in the model.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public FuncDecl[] Decls() throws Z3Exception
|
||||
{
|
||||
int nFuncs = NumFuncs();
|
||||
int nConsts = NumConsts();
|
||||
int n = nFuncs + nConsts;
|
||||
FuncDecl[] res = new FuncDecl[n];
|
||||
for (int i = 0; i < nConsts; i++)
|
||||
res[i] = new FuncDecl(Context(), Native.modelGetConstDecl(Context()
|
||||
.nCtx(), NativeObject(), i));
|
||||
for (int i = 0; i < nFuncs; i++)
|
||||
res[nConsts + i] = new FuncDecl(Context(), Native.modelGetFuncDecl(
|
||||
Context().nCtx(), NativeObject(), i));
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* A ModelEvaluationFailedException is thrown when an expression cannot be
|
||||
* evaluated by the model.
|
||||
**/
|
||||
@SuppressWarnings("serial")
|
||||
public class ModelEvaluationFailedException extends Z3Exception
|
||||
{
|
||||
/**
|
||||
* An exception that is thrown when model evaluation fails.
|
||||
**/
|
||||
public ModelEvaluationFailedException()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluates the expression <paramref name="t"/> in the current model.
|
||||
* <remarks> This function may fail if <paramref name="t"/> contains
|
||||
* quantifiers, is partial (MODEL_PARTIAL enabled), or if <paramref
|
||||
* name="t"/> is not well-sorted. In this case a
|
||||
* <code>ModelEvaluationFailedException</code> is thrown. </remarks> <param
|
||||
* name="t">An expression</param> <param name="completion"> When this flag
|
||||
* is enabled, a model value will be assigned to any constant or function
|
||||
* that does not have an interpretation in the model. </param>
|
||||
*
|
||||
* @return The evaluation of <paramref name="t"/> in the model.
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Expr Eval(Expr t, boolean completion) throws Z3Exception
|
||||
{
|
||||
Native.LongPtr v = new Native.LongPtr();
|
||||
if (Native.modelEval(Context().nCtx(), NativeObject(),
|
||||
t.NativeObject(), (completion) ? true : false, v) ^ true)
|
||||
throw new ModelEvaluationFailedException();
|
||||
else
|
||||
return Expr.Create(Context(), v.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for <code>Eval</code>.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Expr Evaluate(Expr t, boolean completion) throws Z3Exception
|
||||
{
|
||||
return Eval(t, completion);
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of uninterpreted sorts that the model has an interpretation
|
||||
* for.
|
||||
**/
|
||||
public int NumSorts() throws Z3Exception
|
||||
{
|
||||
return Native.modelGetNumSorts(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* The uninterpreted sorts that the model has an interpretation for.
|
||||
* <remarks> Z3 also provides an intepretation for uninterpreted sorts used
|
||||
* in a formula. The interpretation for a sort is a finite set of distinct
|
||||
* values. We say this finite set is the "universe" of the sort. </remarks>
|
||||
* <seealso cref="NumSorts"/> <seealso cref="SortUniverse"/>
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Sort[] Sorts() throws Z3Exception
|
||||
{
|
||||
|
||||
int n = NumSorts();
|
||||
Sort[] res = new Sort[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = Sort.Create(Context(),
|
||||
Native.modelGetSort(Context().nCtx(), NativeObject(), i));
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* The finite set of distinct values that represent the interpretation for
|
||||
* sort <paramref name="s"/>. <seealso cref="Sorts"/> <param name="s">An
|
||||
* uninterpreted sort</param>
|
||||
*
|
||||
* @return An array of expressions, where each is an element of the universe
|
||||
* of <paramref name="s"/>
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Expr[] SortUniverse(Sort s) throws Z3Exception
|
||||
{
|
||||
|
||||
ASTVector nUniv = new ASTVector(Context(), Native.modelGetSortUniverse(
|
||||
Context().nCtx(), NativeObject(), s.NativeObject()));
|
||||
int n = nUniv.Size();
|
||||
Expr[] res = new Expr[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = Expr.Create(Context(), nUniv.get(i).NativeObject());
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Conversion of models to strings.
|
||||
*
|
||||
* @return A string representation of the model.
|
||||
**/
|
||||
public String toString()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Native.modelToString(Context().nCtx(), NativeObject());
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
return "Z3Exception: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
Model(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
void IncRef(long o) throws Z3Exception
|
||||
{
|
||||
Context().Model_DRQ().IncAndClear(Context(), o);
|
||||
super.IncRef(o);
|
||||
}
|
||||
|
||||
void DecRef(long o) throws Z3Exception
|
||||
{
|
||||
Context().Model_DRQ().Add(o);
|
||||
super.DecRef(o);
|
||||
}
|
||||
}
|
31
src/api/java/ModelDecRefQueue.java
Normal file
31
src/api/java/ModelDecRefQueue.java
Normal file
|
@ -0,0 +1,31 @@
|
|||
/**
|
||||
* Copyright (c) 2012 Microsoft Corporation
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
class ModelDecRefQueue extends IDecRefQueue
|
||||
{
|
||||
public void IncRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Native.modelIncRef(ctx.nCtx(), obj);
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
// OK.
|
||||
}
|
||||
}
|
||||
|
||||
public void DecRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Native.modelDecRef(ctx.nCtx(), obj);
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
// OK.
|
||||
}
|
||||
}
|
||||
};
|
91
src/api/java/ParamDescrs.java
Normal file
91
src/api/java/ParamDescrs.java
Normal file
|
@ -0,0 +1,91 @@
|
|||
/**
|
||||
* This file was automatically generated from ParamDescrs.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
import com.microsoft.z3.enumerations.*;
|
||||
|
||||
/**
|
||||
* A ParamDescrs describes a set of parameters.
|
||||
**/
|
||||
public class ParamDescrs extends Z3Object
|
||||
{
|
||||
/**
|
||||
* validate a set of parameters.
|
||||
**/
|
||||
public void Validate(Params p) throws Z3Exception
|
||||
{
|
||||
|
||||
Native.paramsValidate(Context().nCtx(), p.NativeObject(),
|
||||
NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve kind of parameter.
|
||||
**/
|
||||
public Z3_param_kind GetKind(Symbol name) throws Z3Exception
|
||||
{
|
||||
|
||||
return Z3_param_kind.fromInt(Native.paramDescrsGetKind(
|
||||
Context().nCtx(), NativeObject(), name.NativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all names of parameters.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Symbol[] Names() throws Z3Exception
|
||||
{
|
||||
int sz = Native.paramDescrsSize(Context().nCtx(), NativeObject());
|
||||
Symbol[] names = new Symbol[sz];
|
||||
for (int i = 0; i < sz; ++i)
|
||||
{
|
||||
names[i] = Symbol.Create(Context(), Native.paramDescrsGetName(
|
||||
Context().nCtx(), NativeObject(), i));
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
/**
|
||||
* The size of the ParamDescrs.
|
||||
**/
|
||||
public int Size() throws Z3Exception
|
||||
{
|
||||
return Native.paramDescrsSize(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a string representation of the ParamDescrs.
|
||||
**/
|
||||
public String toString()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Native.paramDescrsToString(Context().nCtx(), NativeObject());
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
return "Z3Exception: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
ParamDescrs(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
void IncRef(long o) throws Z3Exception
|
||||
{
|
||||
Context().ParamDescrs_DRQ().IncAndClear(Context(), o);
|
||||
super.IncRef(o);
|
||||
}
|
||||
|
||||
void DecRef(long o) throws Z3Exception
|
||||
{
|
||||
Context().ParamDescrs_DRQ().Add(o);
|
||||
super.DecRef(o);
|
||||
}
|
||||
}
|
31
src/api/java/ParamDescrsDecRefQueue.java
Normal file
31
src/api/java/ParamDescrsDecRefQueue.java
Normal file
|
@ -0,0 +1,31 @@
|
|||
/**
|
||||
* Copyright (c) 2012 Microsoft Corporation
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
class ParamDescrsDecRefQueue extends IDecRefQueue
|
||||
{
|
||||
public void IncRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Native.paramDescrsIncRef(ctx.nCtx(), obj);
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
// OK.
|
||||
}
|
||||
}
|
||||
|
||||
public void DecRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Native.paramDescrsDecRef(ctx.nCtx(), obj);
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
// OK.
|
||||
}
|
||||
}
|
||||
};
|
108
src/api/java/Params.java
Normal file
108
src/api/java/Params.java
Normal file
|
@ -0,0 +1,108 @@
|
|||
/**
|
||||
* This file was automatically generated from Params.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* A ParameterSet represents a configuration in the form of Symbol/value pairs.
|
||||
**/
|
||||
public class Params extends Z3Object
|
||||
{
|
||||
/**
|
||||
* Adds a parameter setting.
|
||||
**/
|
||||
public void Add(Symbol name, boolean value) throws Z3Exception
|
||||
{
|
||||
Native.paramsSetBool(Context().nCtx(), NativeObject(),
|
||||
name.NativeObject(), (value) ? true : false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a parameter setting.
|
||||
**/
|
||||
public void Add(Symbol name, double value) throws Z3Exception
|
||||
{
|
||||
Native.paramsSetDouble(Context().nCtx(), NativeObject(),
|
||||
name.NativeObject(), value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a parameter setting.
|
||||
**/
|
||||
public void Add(Symbol name, Symbol value) throws Z3Exception
|
||||
{
|
||||
|
||||
Native.paramsSetSymbol(Context().nCtx(), NativeObject(),
|
||||
name.NativeObject(), value.NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a parameter setting.
|
||||
**/
|
||||
public void Add(String name, boolean value) throws Z3Exception
|
||||
{
|
||||
Native.paramsSetBool(Context().nCtx(), NativeObject(),
|
||||
Context().MkSymbol(name).NativeObject(), value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a parameter setting.
|
||||
**/
|
||||
public void Add(String name, int value) throws Z3Exception
|
||||
{
|
||||
Native.paramsSetUint(Context().nCtx(), NativeObject(), Context()
|
||||
.MkSymbol(name).NativeObject(), value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a parameter setting.
|
||||
**/
|
||||
public void Add(String name, double value) throws Z3Exception
|
||||
{
|
||||
Native.paramsSetDouble(Context().nCtx(), NativeObject(), Context()
|
||||
.MkSymbol(name).NativeObject(), value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a parameter setting.
|
||||
**/
|
||||
public void Add(String name, Symbol value) throws Z3Exception
|
||||
{
|
||||
Native.paramsSetSymbol(Context().nCtx(), NativeObject(), Context()
|
||||
.MkSymbol(name).NativeObject(), value.NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* A string representation of the parameter set.
|
||||
**/
|
||||
public String toString()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Native.paramsToString(Context().nCtx(), NativeObject());
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
return "Z3Exception: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
Params(Context ctx) throws Z3Exception
|
||||
{
|
||||
super(ctx, Native.mkParams(ctx.nCtx()));
|
||||
}
|
||||
|
||||
void IncRef(long o) throws Z3Exception
|
||||
{
|
||||
Context().Params_DRQ().IncAndClear(Context(), o);
|
||||
super.IncRef(o);
|
||||
}
|
||||
|
||||
void DecRef(long o) throws Z3Exception
|
||||
{
|
||||
Context().Params_DRQ().Add(o);
|
||||
super.DecRef(o);
|
||||
}
|
||||
}
|
31
src/api/java/ParamsDecRefQueue.java
Normal file
31
src/api/java/ParamsDecRefQueue.java
Normal file
|
@ -0,0 +1,31 @@
|
|||
/**
|
||||
* Copyright (c) 2012 Microsoft Corporation
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
class ParamsDecRefQueue extends IDecRefQueue
|
||||
{
|
||||
public void IncRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Native.paramsIncRef(ctx.nCtx(), obj);
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
// OK.
|
||||
}
|
||||
}
|
||||
|
||||
public void DecRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Native.paramsDecRef(ctx.nCtx(), obj);
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
// OK.
|
||||
}
|
||||
}
|
||||
};
|
57
src/api/java/Pattern.java
Normal file
57
src/api/java/Pattern.java
Normal file
|
@ -0,0 +1,57 @@
|
|||
/**
|
||||
* This file was automatically generated from Pattern.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* Patterns comprise a list of terms. The list should be non-empty. If the list
|
||||
* comprises of more than one term, it is also called a multi-pattern.
|
||||
**/
|
||||
public class Pattern extends AST
|
||||
{
|
||||
/**
|
||||
* The number of terms in the pattern.
|
||||
**/
|
||||
public int NumTerms() throws Z3Exception
|
||||
{
|
||||
return Native.getPatternNumTerms(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* The terms in the pattern.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Expr[] Terms() throws Z3Exception
|
||||
{
|
||||
|
||||
int n = NumTerms();
|
||||
Expr[] res = new Expr[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = Expr.Create(Context(),
|
||||
Native.getPattern(Context().nCtx(), NativeObject(), i));
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* A string representation of the pattern.
|
||||
**/
|
||||
public String toString()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Native.patternToString(Context().nCtx(), NativeObject());
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
return "Z3Exception: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
Pattern(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
}
|
63
src/api/java/Probe.java
Normal file
63
src/api/java/Probe.java
Normal file
|
@ -0,0 +1,63 @@
|
|||
/**
|
||||
* This file was automatically generated from Probe.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* Probes are used to inspect a goal (aka problem) and collect information that
|
||||
* may be used to decide which solver and/or preprocessing step will be used.
|
||||
* The complete list of probes may be obtained using the procedures
|
||||
* <code>Context.NumProbes</code> and <code>Context.ProbeNames</code>. It may
|
||||
* also be obtained using the command <code>(help-tactics)</code> in the SMT 2.0
|
||||
* front-end.
|
||||
**/
|
||||
public class Probe extends Z3Object
|
||||
{
|
||||
/**
|
||||
* Execute the probe over the goal.
|
||||
*
|
||||
* @return A probe always produce a double value. "Boolean" probes return
|
||||
* 0.0 for false, and a value different from 0.0 for true.
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public double Apply(Goal g) throws Z3Exception
|
||||
{
|
||||
Context().CheckContextMatch(g);
|
||||
return Native.probeApply(Context().nCtx(), NativeObject(),
|
||||
g.NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the probe to a goal.
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public double get(Goal g) throws Z3Exception
|
||||
{
|
||||
return Apply(g);
|
||||
}
|
||||
|
||||
Probe(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
Probe(Context ctx, String name) throws Z3Exception
|
||||
{
|
||||
super(ctx, Native.mkProbe(ctx.nCtx(), name));
|
||||
}
|
||||
|
||||
void IncRef(long o) throws Z3Exception
|
||||
{
|
||||
Context().Probe_DRQ().IncAndClear(Context(), o);
|
||||
super.IncRef(o);
|
||||
}
|
||||
|
||||
void DecRef(long o) throws Z3Exception
|
||||
{
|
||||
Context().Probe_DRQ().Add(o);
|
||||
super.DecRef(o);
|
||||
}
|
||||
}
|
31
src/api/java/ProbeDecRefQueue.java
Normal file
31
src/api/java/ProbeDecRefQueue.java
Normal file
|
@ -0,0 +1,31 @@
|
|||
/**
|
||||
* Copyright (c) 2012 Microsoft Corporation
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
class ProbeDecRefQueue extends IDecRefQueue
|
||||
{
|
||||
public void IncRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Native.probeIncRef(ctx.nCtx(), obj);
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
// OK.
|
||||
}
|
||||
}
|
||||
|
||||
public void DecRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Native.probeDecRef(ctx.nCtx(), obj);
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
// OK.
|
||||
}
|
||||
}
|
||||
};
|
214
src/api/java/Quantifier.java
Normal file
214
src/api/java/Quantifier.java
Normal file
|
@ -0,0 +1,214 @@
|
|||
/**
|
||||
* This file was automatically generated from Quantifier.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
import com.microsoft.z3.enumerations.*;
|
||||
|
||||
/**
|
||||
* Quantifier expressions.
|
||||
**/
|
||||
public class Quantifier extends BoolExpr
|
||||
{
|
||||
/**
|
||||
* Indicates whether the quantifier is universal.
|
||||
**/
|
||||
public boolean IsUniversal() throws Z3Exception
|
||||
{
|
||||
return Native.isQuantifierForall(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the quantifier is existential.
|
||||
**/
|
||||
public boolean IsExistential() throws Z3Exception
|
||||
{
|
||||
return !IsUniversal();
|
||||
}
|
||||
|
||||
/**
|
||||
* The weight of the quantifier.
|
||||
**/
|
||||
public int Weight() throws Z3Exception
|
||||
{
|
||||
return Native.getQuantifierWeight(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of patterns.
|
||||
**/
|
||||
public int NumPatterns() throws Z3Exception
|
||||
{
|
||||
return Native
|
||||
.getQuantifierNumPatterns(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* The patterns.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Pattern[] Patterns() throws Z3Exception
|
||||
{
|
||||
int n = NumPatterns();
|
||||
Pattern[] res = new Pattern[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = new Pattern(Context(), Native.getQuantifierPatternAst(
|
||||
Context().nCtx(), NativeObject(), i));
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of no-patterns.
|
||||
**/
|
||||
public int NumNoPatterns() throws Z3Exception
|
||||
{
|
||||
return Native.getQuantifierNumNoPatterns(Context().nCtx(),
|
||||
NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* The no-patterns.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Pattern[] NoPatterns() throws Z3Exception
|
||||
{
|
||||
int n = NumNoPatterns();
|
||||
Pattern[] res = new Pattern[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = new Pattern(Context(), Native.getQuantifierNoPatternAst(
|
||||
Context().nCtx(), NativeObject(), i));
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of bound variables.
|
||||
**/
|
||||
public int NumBound() throws Z3Exception
|
||||
{
|
||||
return Native.getQuantifierNumBound(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* The symbols for the bound variables.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Symbol[] BoundVariableNames() throws Z3Exception
|
||||
{
|
||||
int n = NumBound();
|
||||
Symbol[] res = new Symbol[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = Symbol.Create(Context(), Native.getQuantifierBoundName(
|
||||
Context().nCtx(), NativeObject(), i));
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* The sorts of the bound variables.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Sort[] BoundVariableSorts() throws Z3Exception
|
||||
{
|
||||
int n = NumBound();
|
||||
Sort[] res = new Sort[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = Sort.Create(Context(), Native.getQuantifierBoundSort(
|
||||
Context().nCtx(), NativeObject(), i));
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* The body of the quantifier.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public BoolExpr Body() throws Z3Exception
|
||||
{
|
||||
return new BoolExpr(Context(), Native.getQuantifierBody(Context()
|
||||
.nCtx(), NativeObject()));
|
||||
}
|
||||
|
||||
Quantifier(Context ctx, boolean isForall, Sort[] sorts, Symbol[] names,
|
||||
Expr body, int weight, Pattern[] patterns, Expr[] noPatterns,
|
||||
Symbol quantifierID, Symbol skolemID) throws Z3Exception
|
||||
{
|
||||
super(ctx);
|
||||
|
||||
Context().CheckContextMatch(patterns);
|
||||
Context().CheckContextMatch(noPatterns);
|
||||
Context().CheckContextMatch(sorts);
|
||||
Context().CheckContextMatch(names);
|
||||
Context().CheckContextMatch(body);
|
||||
|
||||
if (sorts.length != names.length)
|
||||
throw new Z3Exception(
|
||||
"Number of sorts does not match number of names");
|
||||
|
||||
if (noPatterns == null && quantifierID == null && skolemID == null)
|
||||
{
|
||||
setNativeObject(Native.mkQuantifier(ctx.nCtx(), (isForall) ? true
|
||||
: false, weight, AST.ArrayLength(patterns), AST
|
||||
.ArrayToNative(patterns), AST.ArrayLength(sorts), AST
|
||||
.ArrayToNative(sorts), Symbol.ArrayToNative(names), body
|
||||
.NativeObject()));
|
||||
} else
|
||||
{
|
||||
setNativeObject(Native.mkQuantifierEx(ctx.nCtx(),
|
||||
(isForall) ? true : false, weight, AST.GetNativeObject(quantifierID),
|
||||
AST.GetNativeObject(skolemID),
|
||||
AST.ArrayLength(patterns), AST.ArrayToNative(patterns),
|
||||
AST.ArrayLength(noPatterns), AST.ArrayToNative(noPatterns),
|
||||
AST.ArrayLength(sorts), AST.ArrayToNative(sorts),
|
||||
Symbol.ArrayToNative(names),
|
||||
body.NativeObject()));
|
||||
}
|
||||
}
|
||||
|
||||
Quantifier(Context ctx, boolean isForall, Expr[] bound, Expr body,
|
||||
int weight, Pattern[] patterns, Expr[] noPatterns,
|
||||
Symbol quantifierID, Symbol skolemID) throws Z3Exception
|
||||
{
|
||||
super(ctx);
|
||||
|
||||
Context().CheckContextMatch(noPatterns);
|
||||
Context().CheckContextMatch(patterns);
|
||||
// Context().CheckContextMatch(bound);
|
||||
Context().CheckContextMatch(body);
|
||||
|
||||
if (noPatterns == null && quantifierID == null && skolemID == null)
|
||||
{
|
||||
setNativeObject(Native.mkQuantifierConst(ctx.nCtx(),
|
||||
(isForall) ? true : false, weight, AST.ArrayLength(bound),
|
||||
AST.ArrayToNative(bound), AST.ArrayLength(patterns),
|
||||
AST.ArrayToNative(patterns), body.NativeObject()));
|
||||
} else
|
||||
{
|
||||
setNativeObject(Native.mkQuantifierConstEx(ctx.nCtx(),
|
||||
(isForall) ? true : false, weight,
|
||||
AST.GetNativeObject(quantifierID),
|
||||
AST.GetNativeObject(skolemID), AST.ArrayLength(bound),
|
||||
AST.ArrayToNative(bound), AST.ArrayLength(patterns),
|
||||
AST.ArrayToNative(patterns), AST.ArrayLength(noPatterns),
|
||||
AST.ArrayToNative(noPatterns), body.NativeObject()));
|
||||
}
|
||||
}
|
||||
|
||||
Quantifier(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
void CheckNativeObject(long obj) throws Z3Exception
|
||||
{
|
||||
if (Native.getAstKind(Context().nCtx(), obj) != Z3_ast_kind.Z3_QUANTIFIER_AST
|
||||
.toInt())
|
||||
throw new Z3Exception("Underlying object is not a quantifier");
|
||||
super.CheckNativeObject(obj);
|
||||
}
|
||||
}
|
80
src/api/java/RatNum.java
Normal file
80
src/api/java/RatNum.java
Normal file
|
@ -0,0 +1,80 @@
|
|||
/**
|
||||
* This file was automatically generated from RatNum.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
/**
|
||||
* Rational Numerals
|
||||
**/
|
||||
public class RatNum extends RealExpr
|
||||
{
|
||||
/**
|
||||
* The numerator of a rational numeral.
|
||||
**/
|
||||
public IntNum Numerator() throws Z3Exception
|
||||
{
|
||||
return new IntNum(Context(), Native.getNumerator(Context().nCtx(),
|
||||
NativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* The denominator of a rational numeral.
|
||||
**/
|
||||
public IntNum Denominator() throws Z3Exception
|
||||
{
|
||||
return new IntNum(Context(), Native.getDenominator(Context().nCtx(),
|
||||
NativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the numerator of the rational to a BigInteger
|
||||
**/
|
||||
public BigInteger BigIntNumerator() throws Z3Exception
|
||||
{
|
||||
IntNum n = Numerator();
|
||||
return new BigInteger(n.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the denominator of the rational to a BigInteger
|
||||
**/
|
||||
public BigInteger BigIntDenominator() throws Z3Exception
|
||||
{
|
||||
IntNum n = Denominator();
|
||||
return new BigInteger(n.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation in decimal notation. <remarks>The result
|
||||
* has at most <paramref name="precision"/> decimal places.</remarks>
|
||||
**/
|
||||
public String ToDecimalString(int precision) throws Z3Exception
|
||||
{
|
||||
return Native.getNumeralDecimalString(Context().nCtx(), NativeObject(),
|
||||
precision);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the numeral.
|
||||
**/
|
||||
public String toString()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Native.getNumeralString(Context().nCtx(), NativeObject());
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
return "Z3Exception: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
RatNum(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
}
|
26
src/api/java/RealExpr.java
Normal file
26
src/api/java/RealExpr.java
Normal file
|
@ -0,0 +1,26 @@
|
|||
/**
|
||||
* This file was automatically generated from RealExpr.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* Real expressions
|
||||
**/
|
||||
public class RealExpr extends ArithExpr
|
||||
{
|
||||
/**
|
||||
* Constructor for RealExpr </summary>
|
||||
**/
|
||||
protected RealExpr(Context ctx)
|
||||
{
|
||||
super(ctx);
|
||||
}
|
||||
|
||||
RealExpr(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
}
|
23
src/api/java/RealSort.java
Normal file
23
src/api/java/RealSort.java
Normal file
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* This file was automatically generated from RealSort.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* A real sort
|
||||
**/
|
||||
public class RealSort extends ArithSort
|
||||
{
|
||||
RealSort(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
RealSort(Context ctx) throws Z3Exception
|
||||
{
|
||||
super(ctx, Native.mkRealSort(ctx.nCtx()));
|
||||
}
|
||||
}
|
46
src/api/java/RelationSort.java
Normal file
46
src/api/java/RelationSort.java
Normal file
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
* This file was automatically generated from RelationSort.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* Relation sorts.
|
||||
**/
|
||||
public class RelationSort extends Sort
|
||||
{
|
||||
/**
|
||||
* The arity of the relation sort.
|
||||
**/
|
||||
public int Arity() throws Z3Exception
|
||||
{
|
||||
return Native.getRelationArity(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* The sorts of the columns of the relation sort.
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Sort[] ColumnSorts() throws Z3Exception
|
||||
{
|
||||
|
||||
if (m_columnSorts != null)
|
||||
return m_columnSorts;
|
||||
|
||||
int n = Arity();
|
||||
Sort[] res = new Sort[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = Sort.Create(Context(), Native.getRelationColumn(Context()
|
||||
.nCtx(), NativeObject(), i));
|
||||
return res;
|
||||
}
|
||||
|
||||
private Sort[] m_columnSorts = null;
|
||||
|
||||
RelationSort(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
}
|
23
src/api/java/SetSort.java
Normal file
23
src/api/java/SetSort.java
Normal file
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* This file was automatically generated from SetSort.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* Set sorts.
|
||||
**/
|
||||
public class SetSort extends Sort
|
||||
{
|
||||
SetSort(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
SetSort(Context ctx, Sort ty) throws Z3Exception
|
||||
{
|
||||
super(ctx, Native.mkSetSort(ctx.nCtx(), ty.NativeObject()));
|
||||
}
|
||||
}
|
286
src/api/java/Solver.java
Normal file
286
src/api/java/Solver.java
Normal file
|
@ -0,0 +1,286 @@
|
|||
/**
|
||||
* This file was automatically generated from Solver.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
import com.microsoft.z3.enumerations.*;
|
||||
|
||||
/**
|
||||
* Solvers.
|
||||
**/
|
||||
public class Solver extends Z3Object
|
||||
{
|
||||
/**
|
||||
* A string that describes all available solver parameters.
|
||||
**/
|
||||
public String Help() throws Z3Exception
|
||||
{
|
||||
return Native.solverGetHelp(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the solver parameters.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public void setParameters(Params value) throws Z3Exception
|
||||
{
|
||||
Context().CheckContextMatch(value);
|
||||
Native.solverSetParams(Context().nCtx(), NativeObject(),
|
||||
value.NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves parameter descriptions for solver.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public ParamDescrs ParameterDescriptions() throws Z3Exception
|
||||
{
|
||||
return new ParamDescrs(Context(), Native.solverGetParamDescrs(Context()
|
||||
.nCtx(), NativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* The current number of backtracking points (scopes). <seealso cref="Pop"/>
|
||||
* <seealso cref="Push"/>
|
||||
**/
|
||||
public int NumScopes() throws Z3Exception
|
||||
{
|
||||
return Native.solverGetNumScopes(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a backtracking point. <seealso cref="Pop"/>
|
||||
**/
|
||||
public void Push() throws Z3Exception
|
||||
{
|
||||
Native.solverPush(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Backtracks one backtracking point. <remarks>.
|
||||
**/
|
||||
public void Pop() throws Z3Exception
|
||||
{
|
||||
Pop(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Backtracks <paramref name="n"/> backtracking points. <remarks>Note that
|
||||
* an exception is thrown if <paramref name="n"/> is not smaller than
|
||||
* <code>NumScopes</code></remarks> <seealso cref="Push"/>
|
||||
**/
|
||||
public void Pop(int n) throws Z3Exception
|
||||
{
|
||||
Native.solverPop(Context().nCtx(), NativeObject(), n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the Solver. <remarks>This removes all assertions from the
|
||||
* solver.</remarks>
|
||||
**/
|
||||
public void Reset() throws Z3Exception
|
||||
{
|
||||
Native.solverReset(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert a multiple constraints into the solver.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public void Assert(BoolExpr[] constraints) throws Z3Exception
|
||||
{
|
||||
Context().CheckContextMatch(constraints);
|
||||
for (BoolExpr a : constraints)
|
||||
{
|
||||
Native.solverAssert(Context().nCtx(), NativeObject(),
|
||||
a.NativeObject());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert one constraint into the solver.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public void Assert(BoolExpr constraint) throws Z3Exception
|
||||
{
|
||||
Context().CheckContextMatch(constraint);
|
||||
Native.solverAssert(Context().nCtx(), NativeObject(),
|
||||
constraint.NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of assertions in the solver.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public int NumAssertions() throws Z3Exception
|
||||
{
|
||||
ASTVector ass = new ASTVector(Context(), Native.solverGetAssertions(
|
||||
Context().nCtx(), NativeObject()));
|
||||
return ass.Size();
|
||||
}
|
||||
|
||||
/**
|
||||
* The set of asserted formulas.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public BoolExpr[] Assertions() throws Z3Exception
|
||||
{
|
||||
ASTVector ass = new ASTVector(Context(), Native.solverGetAssertions(
|
||||
Context().nCtx(), NativeObject()));
|
||||
int n = ass.Size();
|
||||
BoolExpr[] res = new BoolExpr[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = new BoolExpr(Context(), ass.get(i).NativeObject());
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the assertions in the solver are consistent or not.
|
||||
* <remarks> <seealso cref="Model"/> <seealso cref="UnsatCore"/> <seealso
|
||||
* cref="Proof"/> </remarks>
|
||||
**/
|
||||
public Status Check(Expr[] assumptions) throws Z3Exception
|
||||
{
|
||||
Z3_lbool r;
|
||||
if (assumptions == null)
|
||||
r = Z3_lbool.fromInt(Native.solverCheck(Context().nCtx(),
|
||||
NativeObject()));
|
||||
else
|
||||
r = Z3_lbool.fromInt(Native.solverCheckAssumptions(
|
||||
Context().nCtx(), NativeObject(), (int) assumptions.length,
|
||||
AST.ArrayToNative(assumptions)));
|
||||
switch (r)
|
||||
{
|
||||
case Z3_L_TRUE:
|
||||
return Status.SATISFIABLE;
|
||||
case Z3_L_FALSE:
|
||||
return Status.UNSATISFIABLE;
|
||||
default:
|
||||
return Status.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the assertions in the solver are consistent or not.
|
||||
* <remarks> <seealso cref="Model"/> <seealso cref="UnsatCore"/> <seealso
|
||||
* cref="Proof"/> </remarks>
|
||||
**/
|
||||
public Status Check() throws Z3Exception
|
||||
{
|
||||
return Check(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* The model of the last <code>Check</code>. <remarks> The result is
|
||||
* <code>null</code> if <code>Check</code> was not invoked before, if its
|
||||
* results was not <code>SATISFIABLE</code>, or if model production is not
|
||||
* enabled. </remarks>
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Model Model() throws Z3Exception
|
||||
{
|
||||
long x = Native.solverGetModel(Context().nCtx(), NativeObject());
|
||||
if (x == 0)
|
||||
return null;
|
||||
else
|
||||
return new Model(Context(), x);
|
||||
}
|
||||
|
||||
/**
|
||||
* The proof of the last <code>Check</code>. <remarks> The result is
|
||||
* <code>null</code> if <code>Check</code> was not invoked before, if its
|
||||
* results was not <code>UNSATISFIABLE</code>, or if proof production is
|
||||
* disabled. </remarks>
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Expr Proof() throws Z3Exception
|
||||
{
|
||||
long x = Native.solverGetProof(Context().nCtx(), NativeObject());
|
||||
if (x == 0)
|
||||
return null;
|
||||
else
|
||||
return Expr.Create(Context(), x);
|
||||
}
|
||||
|
||||
/**
|
||||
* The unsat core of the last <code>Check</code>. <remarks> The unsat core
|
||||
* is a subset of <code>Assertions</code> The result is empty if
|
||||
* <code>Check</code> was not invoked before, if its results was not
|
||||
* <code>UNSATISFIABLE</code>, or if core production is disabled. </remarks>
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Expr[] UnsatCore() throws Z3Exception
|
||||
{
|
||||
|
||||
ASTVector core = new ASTVector(Context(), Native.solverGetUnsatCore(
|
||||
Context().nCtx(), NativeObject()));
|
||||
int n = core.Size();
|
||||
Expr[] res = new Expr[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = Expr.Create(Context(), core.get(i).NativeObject());
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* A brief justification of why the last call to <code>Check</code> returned
|
||||
* <code>UNKNOWN</code>.
|
||||
**/
|
||||
public String ReasonUnknown() throws Z3Exception
|
||||
{
|
||||
return Native.solverGetReasonUnknown(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Solver statistics.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Statistics Statistics() throws Z3Exception
|
||||
{
|
||||
return new Statistics(Context(), Native.solverGetStatistics(Context()
|
||||
.nCtx(), NativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* A string representation of the solver.
|
||||
**/
|
||||
public String toString()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Native.solverToString(Context().nCtx(), NativeObject());
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
return "Z3Exception: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
Solver(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
void IncRef(long o) throws Z3Exception
|
||||
{
|
||||
Context().Solver_DRQ().IncAndClear(Context(), o);
|
||||
super.IncRef(o);
|
||||
}
|
||||
|
||||
void DecRef(long o) throws Z3Exception
|
||||
{
|
||||
Context().Solver_DRQ().Add(o);
|
||||
super.DecRef(o);
|
||||
}
|
||||
}
|
31
src/api/java/SolverDecRefQueue.java
Normal file
31
src/api/java/SolverDecRefQueue.java
Normal file
|
@ -0,0 +1,31 @@
|
|||
/**
|
||||
* Copyright (c) 2012 Microsoft Corporation
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
class SolverDecRefQueue extends IDecRefQueue
|
||||
{
|
||||
public void IncRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Native.solverIncRef(ctx.nCtx(), obj);
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
// OK.
|
||||
}
|
||||
}
|
||||
|
||||
public void DecRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Native.solverDecRef(ctx.nCtx(), obj);
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
// OK.
|
||||
}
|
||||
}
|
||||
};
|
154
src/api/java/Sort.java
Normal file
154
src/api/java/Sort.java
Normal file
|
@ -0,0 +1,154 @@
|
|||
/**
|
||||
* This file was automatically generated from Sort.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
import com.microsoft.z3.enumerations.*;
|
||||
|
||||
/**
|
||||
* The Sort class implements type information for ASTs.
|
||||
**/
|
||||
public class Sort extends AST
|
||||
{
|
||||
/**
|
||||
* Comparison operator. <param name="a">A Sort</param> <param name="b">A
|
||||
* Sort</param>
|
||||
*
|
||||
* @return True if <paramref name="a"/> and <paramref name="b"/> are from
|
||||
* the same context and represent the same sort; false otherwise.
|
||||
**/
|
||||
/* Overloaded operators are not translated. */
|
||||
|
||||
/**
|
||||
* Comparison operator. <param name="a">A Sort</param> <param name="b">A
|
||||
* Sort</param>
|
||||
*
|
||||
* @return True if <paramref name="a"/> and <paramref name="b"/> are not
|
||||
* from the same context or represent different sorts; false
|
||||
* otherwise.
|
||||
**/
|
||||
/* Overloaded operators are not translated. */
|
||||
|
||||
/**
|
||||
* Equality operator for objects of type Sort. <param name="o"></param>
|
||||
*
|
||||
* @return
|
||||
**/
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
Sort casted = null;
|
||||
|
||||
try {
|
||||
casted = Sort.class.cast(o);
|
||||
} catch (ClassCastException e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.NativeObject() == casted.NativeObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash code generation for Sorts
|
||||
*
|
||||
* @return A hash code
|
||||
**/
|
||||
public int GetHashCode() throws Z3Exception
|
||||
{
|
||||
return super.GetHashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a unique identifier for the sort.
|
||||
**/
|
||||
public int Id() throws Z3Exception
|
||||
{
|
||||
return Native.getSortId(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* The kind of the sort.
|
||||
**/
|
||||
public Z3_sort_kind SortKind() throws Z3Exception
|
||||
{
|
||||
return Z3_sort_kind.fromInt(Native.getSortKind(Context().nCtx(),
|
||||
NativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the sort
|
||||
**/
|
||||
public Symbol Name() throws Z3Exception
|
||||
{
|
||||
return Symbol.Create(Context(),
|
||||
Native.getSortName(Context().nCtx(), NativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* A string representation of the sort.
|
||||
**/
|
||||
public String toString()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Native.sortToString(Context().nCtx(), NativeObject());
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
return "Z3Exception: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort constructor
|
||||
**/
|
||||
protected Sort(Context ctx) throws Z3Exception
|
||||
{
|
||||
super(ctx);
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
Sort(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
void CheckNativeObject(long obj) throws Z3Exception
|
||||
{
|
||||
if (Native.getAstKind(Context().nCtx(), obj) != Z3_ast_kind.Z3_SORT_AST
|
||||
.toInt())
|
||||
throw new Z3Exception("Underlying object is not a sort");
|
||||
super.CheckNativeObject(obj);
|
||||
}
|
||||
|
||||
static Sort Create(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
switch (Z3_sort_kind.fromInt(Native.getSortKind(ctx.nCtx(), obj)))
|
||||
{
|
||||
case Z3_ARRAY_SORT:
|
||||
return new ArraySort(ctx, obj);
|
||||
case Z3_BOOL_SORT:
|
||||
return new BoolSort(ctx, obj);
|
||||
case Z3_BV_SORT:
|
||||
return new BitVecSort(ctx, obj);
|
||||
case Z3_DATATYPE_SORT:
|
||||
return new DatatypeSort(ctx, obj);
|
||||
case Z3_INT_SORT:
|
||||
return new IntSort(ctx, obj);
|
||||
case Z3_REAL_SORT:
|
||||
return new RealSort(ctx, obj);
|
||||
case Z3_UNINTERPRETED_SORT:
|
||||
return new UninterpretedSort(ctx, obj);
|
||||
case Z3_FINITE_DOMAIN_SORT:
|
||||
return new FiniteDomainSort(ctx, obj);
|
||||
case Z3_RELATION_SORT:
|
||||
return new RelationSort(ctx, obj);
|
||||
default:
|
||||
throw new Z3Exception("Unknown sort kind");
|
||||
}
|
||||
}
|
||||
}
|
199
src/api/java/Statistics.java
Normal file
199
src/api/java/Statistics.java
Normal file
|
@ -0,0 +1,199 @@
|
|||
/**
|
||||
* This file was automatically generated from Statistics.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* Objects of this class track statistical information about solvers.
|
||||
**/
|
||||
public class Statistics extends Z3Object
|
||||
{
|
||||
/**
|
||||
* Statistical data is organized into pairs of [Key, Entry], where every
|
||||
* Entry is either a <code>DoubleEntry</code> or a <code>UIntEntry</code>
|
||||
**/
|
||||
public class Entry
|
||||
{
|
||||
/**
|
||||
* The key of the entry.
|
||||
**/
|
||||
public String Key;
|
||||
|
||||
/**
|
||||
* The uint-value of the entry.
|
||||
**/
|
||||
public int UIntValue()
|
||||
{
|
||||
return m_int;
|
||||
}
|
||||
|
||||
/**
|
||||
* The double-value of the entry.
|
||||
**/
|
||||
public double DoubleValue()
|
||||
{
|
||||
return m_double;
|
||||
}
|
||||
|
||||
/**
|
||||
* True if the entry is uint-valued.
|
||||
**/
|
||||
public boolean IsUInt()
|
||||
{
|
||||
return m_is_int;
|
||||
}
|
||||
|
||||
/**
|
||||
* True if the entry is double-valued.
|
||||
**/
|
||||
public boolean IsDouble()
|
||||
{
|
||||
return m_is_double;
|
||||
}
|
||||
|
||||
/**
|
||||
* The string representation of the the entry's value.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public String Value() throws Z3Exception
|
||||
{
|
||||
if (IsUInt())
|
||||
return Integer.toString(m_int);
|
||||
else if (IsDouble())
|
||||
return Double.toString(m_double);
|
||||
else
|
||||
throw new Z3Exception("Unknown statistical entry type");
|
||||
}
|
||||
|
||||
/**
|
||||
* The string representation of the Entry.
|
||||
**/
|
||||
public String toString()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Key + ": " + Value();
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
return new String("Z3Exception: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean m_is_int = false;
|
||||
private boolean m_is_double = false;
|
||||
private int m_int = 0;
|
||||
private double m_double = 0.0;
|
||||
|
||||
Entry(String k, int v)
|
||||
{
|
||||
Key = k;
|
||||
m_is_int = true;
|
||||
m_int = v;
|
||||
}
|
||||
|
||||
Entry(String k, double v)
|
||||
{
|
||||
Key = k;
|
||||
m_is_double = true;
|
||||
m_double = v;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A string representation of the statistical data.
|
||||
**/
|
||||
public String toString()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Native.statsToString(Context().nCtx(), NativeObject());
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
return "Z3Exception: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of statistical data.
|
||||
**/
|
||||
public int Size() throws Z3Exception
|
||||
{
|
||||
return Native.statsSize(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* The data entries.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Entry[] Entries() throws Z3Exception
|
||||
{
|
||||
|
||||
int n = Size();
|
||||
Entry[] res = new Entry[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
Entry e;
|
||||
String k = Native.statsGetKey(Context().nCtx(), NativeObject(), i);
|
||||
if (Native.statsIsUint(Context().nCtx(), NativeObject(), i))
|
||||
e = new Entry(k, Native.statsGetUintValue(Context().nCtx(),
|
||||
NativeObject(), i));
|
||||
else if (Native.statsIsDouble(Context().nCtx(), NativeObject(), i))
|
||||
e = new Entry(k, Native.statsGetDoubleValue(Context().nCtx(),
|
||||
NativeObject(), i));
|
||||
else
|
||||
throw new Z3Exception("Unknown data entry value");
|
||||
res[i] = e;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* The statistical counters.
|
||||
**/
|
||||
public String[] Keys() throws Z3Exception
|
||||
{
|
||||
int n = Size();
|
||||
String[] res = new String[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = Native.statsGetKey(Context().nCtx(), NativeObject(), i);
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* The value of a particular statistical counter. <remarks>Returns null if
|
||||
* the key is unknown.</remarks>
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Entry get(String key) throws Z3Exception
|
||||
{
|
||||
int n = Size();
|
||||
Entry[] es = Entries();
|
||||
for (int i = 0; i < n; i++)
|
||||
if (es[i].Key == key)
|
||||
return es[i];
|
||||
return null;
|
||||
}
|
||||
|
||||
Statistics(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
void IncRef(long o) throws Z3Exception
|
||||
{
|
||||
Context().Statistics_DRQ().IncAndClear(Context(), o);
|
||||
super.IncRef(o);
|
||||
}
|
||||
|
||||
void DecRef(long o) throws Z3Exception
|
||||
{
|
||||
Context().Statistics_DRQ().Add(o);
|
||||
super.DecRef(o);
|
||||
}
|
||||
}
|
31
src/api/java/StatisticsDecRefQueue.java
Normal file
31
src/api/java/StatisticsDecRefQueue.java
Normal file
|
@ -0,0 +1,31 @@
|
|||
/**
|
||||
* Copyright (c) 2012 Microsoft Corporation
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
class StatisticsDecRefQueue extends IDecRefQueue
|
||||
{
|
||||
public void IncRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Native.statsIncRef(ctx.nCtx(), obj);
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
// OK.
|
||||
}
|
||||
}
|
||||
|
||||
public void DecRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Native.statsDecRef(ctx.nCtx(), obj);
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
// OK.
|
||||
}
|
||||
}
|
||||
};
|
42
src/api/java/Status.java
Normal file
42
src/api/java/Status.java
Normal file
|
@ -0,0 +1,42 @@
|
|||
/**
|
||||
* This file was automatically generated from Status.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* Status values.
|
||||
**/
|
||||
public enum Status
|
||||
{
|
||||
// / Used to signify an unsatisfiable status.
|
||||
UNSATISFIABLE(1),
|
||||
|
||||
// / Used to signify an unknown status.
|
||||
UNKNOWN(0),
|
||||
|
||||
// / Used to signify a satisfiable status.
|
||||
SATISFIABLE(1);
|
||||
|
||||
private final int intValue;
|
||||
|
||||
Status(int v)
|
||||
{
|
||||
this.intValue = v;
|
||||
}
|
||||
|
||||
public static final Status fromInt(int v)
|
||||
{
|
||||
for (Status k : values())
|
||||
if (k.intValue == v)
|
||||
return k;
|
||||
return values()[0];
|
||||
}
|
||||
|
||||
public final int toInt()
|
||||
{
|
||||
return this.intValue;
|
||||
}
|
||||
}
|
43
src/api/java/StringSymbol.java
Normal file
43
src/api/java/StringSymbol.java
Normal file
|
@ -0,0 +1,43 @@
|
|||
/**
|
||||
* This file was automatically generated from StringSymbol.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
import com.microsoft.z3.enumerations.*;
|
||||
|
||||
/**
|
||||
* Named symbols
|
||||
**/
|
||||
public class StringSymbol extends Symbol
|
||||
{
|
||||
/**
|
||||
* The string value of the symbol. <remarks>Throws an exception if the
|
||||
* symbol is not of string kind.</remarks>
|
||||
**/
|
||||
public String String() throws Z3Exception
|
||||
{
|
||||
return Native.getSymbolString(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
StringSymbol(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
StringSymbol(Context ctx, String s) throws Z3Exception
|
||||
{
|
||||
super(ctx, Native.mkStringSymbol(ctx.nCtx(), s));
|
||||
}
|
||||
|
||||
void CheckNativeObject(long obj) throws Z3Exception
|
||||
{
|
||||
if (Native.getSymbolKind(Context().nCtx(), obj) != Z3_symbol_kind.Z3_STRING_SYMBOL
|
||||
.toInt())
|
||||
throw new Z3Exception("Symbol is not of String kind");
|
||||
|
||||
super.CheckNativeObject(obj);
|
||||
}
|
||||
}
|
81
src/api/java/Symbol.java
Normal file
81
src/api/java/Symbol.java
Normal file
|
@ -0,0 +1,81 @@
|
|||
/**
|
||||
* This file was automatically generated from Symbol.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
import com.microsoft.z3.enumerations.*;
|
||||
|
||||
/**
|
||||
* Symbols are used to name several term and type constructors.
|
||||
**/
|
||||
public class Symbol extends Z3Object
|
||||
{
|
||||
/**
|
||||
* The kind of the symbol (int or string)
|
||||
**/
|
||||
protected Z3_symbol_kind Kind() throws Z3Exception
|
||||
{
|
||||
return Z3_symbol_kind.fromInt(Native.getSymbolKind(Context().nCtx(),
|
||||
NativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the symbol is of Int kind
|
||||
**/
|
||||
public boolean IsIntSymbol() throws Z3Exception
|
||||
{
|
||||
return Kind() == Z3_symbol_kind.Z3_INT_SYMBOL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the symbol is of string kind.
|
||||
**/
|
||||
public boolean IsStringSymbol() throws Z3Exception
|
||||
{
|
||||
return Kind() == Z3_symbol_kind.Z3_STRING_SYMBOL;
|
||||
}
|
||||
|
||||
/**
|
||||
* A string representation of the symbol.
|
||||
**/
|
||||
public String toString()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (IsIntSymbol())
|
||||
return Integer.toString(((IntSymbol) this).Int());
|
||||
else if (IsStringSymbol())
|
||||
return ((StringSymbol) this).String();
|
||||
else
|
||||
return new String(
|
||||
"Z3Exception: Unknown symbol kind encountered.");
|
||||
} catch (Z3Exception ex)
|
||||
{
|
||||
return new String("Z3Exception: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Symbol constructor
|
||||
**/
|
||||
protected Symbol(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
static Symbol Create(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
switch (Z3_symbol_kind.fromInt(Native.getSymbolKind(ctx.nCtx(), obj)))
|
||||
{
|
||||
case Z3_INT_SYMBOL:
|
||||
return new IntSymbol(ctx, obj);
|
||||
case Z3_STRING_SYMBOL:
|
||||
return new StringSymbol(ctx, obj);
|
||||
default:
|
||||
throw new Z3Exception("Unknown symbol kind encountered");
|
||||
}
|
||||
}
|
||||
}
|
107
src/api/java/Tactic.java
Normal file
107
src/api/java/Tactic.java
Normal file
|
@ -0,0 +1,107 @@
|
|||
/**
|
||||
* This file was automatically generated from Tactic.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* Tactics are the basic building block for creating custom solvers for specific
|
||||
* problem domains. The complete list of tactics may be obtained using
|
||||
* <code>Context.NumTactics</code> and <code>Context.TacticNames</code>. It may
|
||||
* also be obtained using the command <code>(help-tactics)</code> in the SMT 2.0
|
||||
* front-end.
|
||||
**/
|
||||
public class Tactic extends Z3Object
|
||||
{
|
||||
/**
|
||||
* A string containing a description of parameters accepted by the tactic.
|
||||
**/
|
||||
public String Help() throws Z3Exception
|
||||
{
|
||||
return Native.tacticGetHelp(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves parameter descriptions for Tactics.
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public ParamDescrs ParameterDescriptions() throws Z3Exception
|
||||
{
|
||||
return new ParamDescrs(Context(), Native.tacticGetParamDescrs(Context()
|
||||
.nCtx(), NativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the tactic over the goal.
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public ApplyResult Apply(Goal g) throws Z3Exception
|
||||
{
|
||||
return Apply(g, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the tactic over the goal.
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public ApplyResult Apply(Goal g, Params p) throws Z3Exception
|
||||
{
|
||||
|
||||
Context().CheckContextMatch(g);
|
||||
if (p == null)
|
||||
return new ApplyResult(Context(), Native.tacticApply(Context()
|
||||
.nCtx(), NativeObject(), g.NativeObject()));
|
||||
else
|
||||
{
|
||||
Context().CheckContextMatch(p);
|
||||
return new ApplyResult(Context(),
|
||||
Native.tacticApplyEx(Context().nCtx(), NativeObject(),
|
||||
g.NativeObject(), p.NativeObject()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the tactic to a goal.
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public ApplyResult get(Goal g) throws Z3Exception
|
||||
{
|
||||
|
||||
return Apply(g, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a solver that is implemented using the given tactic. <seealso
|
||||
* cref="Context.MkSolver(Tactic)"/>
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Solver Solver() throws Z3Exception
|
||||
{
|
||||
|
||||
return Context().MkSolver(this);
|
||||
}
|
||||
|
||||
Tactic(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
Tactic(Context ctx, String name) throws Z3Exception
|
||||
{
|
||||
super(ctx, Native.mkTactic(ctx.nCtx(), name));
|
||||
}
|
||||
|
||||
void IncRef(long o) throws Z3Exception
|
||||
{
|
||||
Context().Tactic_DRQ().IncAndClear(Context(), o);
|
||||
super.IncRef(o);
|
||||
}
|
||||
|
||||
void DecRef(long o) throws Z3Exception
|
||||
{
|
||||
Context().Tactic_DRQ().Add(o);
|
||||
super.DecRef(o);
|
||||
}
|
||||
}
|
31
src/api/java/TacticDecRefQueue.java
Normal file
31
src/api/java/TacticDecRefQueue.java
Normal file
|
@ -0,0 +1,31 @@
|
|||
/**
|
||||
* Copyright (c) 2012 Microsoft Corporation
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
class TacticDecRefQueue extends IDecRefQueue
|
||||
{
|
||||
public void IncRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Native.tacticIncRef(ctx.nCtx(), obj);
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
// OK.
|
||||
}
|
||||
}
|
||||
|
||||
public void DecRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Native.tacticDecRef(ctx.nCtx(), obj);
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
// OK.
|
||||
}
|
||||
}
|
||||
};
|
58
src/api/java/TupleSort.java
Normal file
58
src/api/java/TupleSort.java
Normal file
|
@ -0,0 +1,58 @@
|
|||
/**
|
||||
* This file was automatically generated from TupleSort.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* Tuple sorts.
|
||||
**/
|
||||
public class TupleSort extends Sort
|
||||
{
|
||||
/**
|
||||
* The constructor function of the tuple.
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public FuncDecl MkDecl() throws Z3Exception
|
||||
{
|
||||
|
||||
return new FuncDecl(Context(), Native.getTupleSortMkDecl(Context()
|
||||
.nCtx(), NativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of fields in the tuple.
|
||||
**/
|
||||
public int NumFields() throws Z3Exception
|
||||
{
|
||||
return Native.getTupleSortNumFields(Context().nCtx(), NativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* The field declarations.
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public FuncDecl[] FieldDecls() throws Z3Exception
|
||||
{
|
||||
|
||||
int n = NumFields();
|
||||
FuncDecl[] res = new FuncDecl[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = new FuncDecl(Context(), Native.getTupleSortFieldDecl(
|
||||
Context().nCtx(), NativeObject(), i));
|
||||
return res;
|
||||
}
|
||||
|
||||
TupleSort(Context ctx, Symbol name, int numFields, Symbol[] fieldNames,
|
||||
Sort[] fieldSorts) throws Z3Exception
|
||||
{
|
||||
super(ctx);
|
||||
|
||||
Native.LongPtr t = new Native.LongPtr();
|
||||
setNativeObject(Native.mkTupleSort(ctx.nCtx(), name.NativeObject(),
|
||||
numFields, Symbol.ArrayToNative(fieldNames),
|
||||
AST.ArrayToNative(fieldSorts), t, new long[numFields]));
|
||||
}
|
||||
};
|
23
src/api/java/UninterpretedSort.java
Normal file
23
src/api/java/UninterpretedSort.java
Normal file
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* This file was automatically generated from UninterpretedSort.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* Uninterpreted Sorts
|
||||
**/
|
||||
public class UninterpretedSort extends Sort
|
||||
{
|
||||
UninterpretedSort(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
UninterpretedSort(Context ctx, Symbol s) throws Z3Exception
|
||||
{
|
||||
super(ctx, Native.mkUninterpretedSort(ctx.nCtx(), s.NativeObject()));
|
||||
}
|
||||
}
|
64
src/api/java/Version.java
Normal file
64
src/api/java/Version.java
Normal file
|
@ -0,0 +1,64 @@
|
|||
/**
|
||||
* This file was automatically generated from Version.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* Version information. <remarks>Note that this class is static.</remarks>
|
||||
**/
|
||||
public class Version
|
||||
{
|
||||
/**
|
||||
* The major version
|
||||
**/
|
||||
public static int Major()
|
||||
{
|
||||
Native.IntPtr major = new Native.IntPtr(), minor = new Native.IntPtr(), build = new Native.IntPtr(), revision = new Native.IntPtr();
|
||||
Native.getVersion(major, minor, build, revision);
|
||||
return major.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* The minor version
|
||||
**/
|
||||
public static int Minor()
|
||||
{
|
||||
Native.IntPtr major = new Native.IntPtr(), minor = new Native.IntPtr(), build = new Native.IntPtr(), revision = new Native.IntPtr();
|
||||
Native.getVersion(major, minor, build, revision);
|
||||
return minor.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* The build version
|
||||
**/
|
||||
public static int Build()
|
||||
{
|
||||
Native.IntPtr major = new Native.IntPtr(), minor = new Native.IntPtr(), build = new Native.IntPtr(), revision = new Native.IntPtr();
|
||||
Native.getVersion(major, minor, build, revision);
|
||||
return build.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* The revision
|
||||
**/
|
||||
public static int Revision()
|
||||
{
|
||||
Native.IntPtr major = new Native.IntPtr(), minor = new Native.IntPtr(), build = new Native.IntPtr(), revision = new Native.IntPtr();
|
||||
Native.getVersion(major, minor, build, revision);
|
||||
return revision.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* A string representation of the version information.
|
||||
**/
|
||||
public static String getString()
|
||||
{
|
||||
Native.IntPtr major = new Native.IntPtr(), minor = new Native.IntPtr(), build = new Native.IntPtr(), revision = new Native.IntPtr();
|
||||
Native.getVersion(major, minor, build, revision);
|
||||
return Integer.toString(major.value) + "." + Integer.toString(minor.value) + "."
|
||||
+ Integer.toString(build.value) + "." + Integer.toString(revision.value);
|
||||
}
|
||||
}
|
40
src/api/java/Z3Exception.java
Normal file
40
src/api/java/Z3Exception.java
Normal file
|
@ -0,0 +1,40 @@
|
|||
/**
|
||||
* This file was automatically generated from Z3Exception.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
import java.lang.Exception;
|
||||
|
||||
/**
|
||||
* The exception base class for error reporting from Z3
|
||||
**/
|
||||
@SuppressWarnings("serial")
|
||||
public class Z3Exception extends Exception
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
**/
|
||||
public Z3Exception()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
**/
|
||||
public Z3Exception(String message)
|
||||
{
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
**/
|
||||
public Z3Exception(String message, Exception inner)
|
||||
{
|
||||
super(message, inner);
|
||||
}
|
||||
}
|
115
src/api/java/Z3Object.java
Normal file
115
src/api/java/Z3Object.java
Normal file
|
@ -0,0 +1,115 @@
|
|||
/**
|
||||
* This file was automatically generated from Z3Object.cs
|
||||
* w/ further modifications by:
|
||||
* @author Christoph M. Wintersteiger (cwinter)
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
/**
|
||||
* Internal base class for interfacing with native Z3 objects. Should not be
|
||||
* used externally.
|
||||
**/
|
||||
public class Z3Object extends IDisposable
|
||||
{
|
||||
/**
|
||||
* Finalizer.
|
||||
**/
|
||||
protected void finalize() throws Z3Exception
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
|
||||
/**
|
||||
* Disposes of the underlying native Z3 object.
|
||||
**/
|
||||
public void Dispose() throws Z3Exception
|
||||
{
|
||||
if (m_n_obj != 0)
|
||||
{
|
||||
DecRef(m_n_obj);
|
||||
m_n_obj = 0;
|
||||
}
|
||||
|
||||
if (m_ctx != null)
|
||||
{
|
||||
m_ctx.m_refCount--;
|
||||
m_ctx = null;
|
||||
}
|
||||
}
|
||||
|
||||
private Context m_ctx = null;
|
||||
private long m_n_obj = 0;
|
||||
|
||||
Z3Object(Context ctx)
|
||||
{
|
||||
ctx.m_refCount++;
|
||||
m_ctx = ctx;
|
||||
}
|
||||
|
||||
Z3Object(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
ctx.m_refCount++;
|
||||
m_ctx = ctx;
|
||||
IncRef(obj);
|
||||
m_n_obj = obj;
|
||||
}
|
||||
|
||||
void IncRef(long o) throws Z3Exception
|
||||
{
|
||||
}
|
||||
|
||||
void DecRef(long o) throws Z3Exception
|
||||
{
|
||||
}
|
||||
|
||||
void CheckNativeObject(long obj) throws Z3Exception
|
||||
{
|
||||
}
|
||||
|
||||
long NativeObject()
|
||||
{
|
||||
return m_n_obj;
|
||||
}
|
||||
|
||||
void setNativeObject(long value) throws Z3Exception
|
||||
{
|
||||
if (value != 0)
|
||||
{
|
||||
CheckNativeObject(value);
|
||||
IncRef(value);
|
||||
}
|
||||
if (m_n_obj != 0)
|
||||
{
|
||||
DecRef(m_n_obj);
|
||||
}
|
||||
m_n_obj = value;
|
||||
}
|
||||
|
||||
static long GetNativeObject(Z3Object s)
|
||||
{
|
||||
if (s == null)
|
||||
return 0;
|
||||
return s.NativeObject();
|
||||
}
|
||||
|
||||
Context Context()
|
||||
{
|
||||
return m_ctx;
|
||||
}
|
||||
|
||||
static long[] ArrayToNative(Z3Object[] a)
|
||||
{
|
||||
if (a == null)
|
||||
return null;
|
||||
long[] an = new long[a.length];
|
||||
for (int i = 0; i < a.length; i++)
|
||||
an[i] = (a[i] == null) ? 0 : a[i].NativeObject();
|
||||
return an;
|
||||
}
|
||||
|
||||
static int ArrayLength(Z3Object[] a)
|
||||
{
|
||||
return (a == null) ? 0 : a.length;
|
||||
}
|
||||
}
|
|
@ -1,209 +0,0 @@
|
|||
/**
|
||||
* This file was automatically generated from AST.cs
|
||||
**/
|
||||
|
||||
package com.Microsoft.Z3;
|
||||
|
||||
/* using System; */
|
||||
/* using System.Collections; */
|
||||
/* using System.Collections.Generic; */
|
||||
|
||||
/**
|
||||
* The abstract syntax tree (AST) class.
|
||||
**/
|
||||
public class AST extends Z3Object
|
||||
{
|
||||
/**
|
||||
* Comparison operator.
|
||||
* <param name="a">An AST</param>
|
||||
* <param name="b">An AST</param>
|
||||
* @return True if <paramref name="a"/> and <paramref name="b"/> are from the same context
|
||||
* and represent the same sort; false otherwise.
|
||||
**/
|
||||
/* Overloaded operators are not translated. */
|
||||
|
||||
/**
|
||||
* Comparison operator.
|
||||
* <param name="a">An AST</param>
|
||||
* <param name="b">An AST</param>
|
||||
* @return True if <paramref name="a"/> and <paramref name="b"/> are not from the same context
|
||||
* or represent different sorts; false otherwise.
|
||||
**/
|
||||
/* Overloaded operators are not translated. */
|
||||
|
||||
/**
|
||||
* Object comparison.
|
||||
**/
|
||||
public boolean Equals(object o)
|
||||
{
|
||||
AST casted = (AST) o;
|
||||
if (casted == null) return false;
|
||||
return this == casted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Object Comparison.
|
||||
* <param name="other">Another AST</param>
|
||||
* @return Negative if the object should be sorted before <paramref name="other"/>, positive if after else zero.
|
||||
**/
|
||||
public int CompareTo(object other)
|
||||
{
|
||||
if (other == null) return 1;
|
||||
AST oAST = (AST) other;
|
||||
if (oAST == null)
|
||||
return 1;
|
||||
else
|
||||
{
|
||||
if (Id < oAST.Id)
|
||||
return -1;
|
||||
else if (Id > oAST.Id)
|
||||
return +1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The AST's hash code.
|
||||
* @return A hash code
|
||||
**/
|
||||
public int GetHashCode()
|
||||
{
|
||||
return (int)Native.getAstHash(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* A unique identifier for the AST (unique among all ASTs).
|
||||
**/
|
||||
public long Id() { return Native.getAstId(Context.nCtx, NativeObject); }
|
||||
|
||||
/**
|
||||
* Translates (copies) the AST to the Context <paramref name="ctx"/>.
|
||||
* <param name="ctx">A context</param>
|
||||
* @return A copy of the AST which is associated with <paramref name="ctx"/>
|
||||
**/
|
||||
public AST Translate(Context ctx)
|
||||
{
|
||||
|
||||
|
||||
|
||||
if (ReferenceEquals(Context, ctx))
|
||||
return this;
|
||||
else
|
||||
return new AST(ctx, Native.translate(Context.nCtx, NativeObject, ctx.nCtx));
|
||||
}
|
||||
|
||||
/**
|
||||
* The kind of the AST.
|
||||
**/
|
||||
public Z3_ast_kind ASTKind() { return (Z3_ast_kind)Native.getAstKind(Context.nCtx, NativeObject); }
|
||||
|
||||
/**
|
||||
* Indicates whether the AST is an Expr
|
||||
**/
|
||||
public boolean IsExpr()
|
||||
{
|
||||
switch (ASTKind)
|
||||
{
|
||||
case Z3_ast_kind.Z3_APP_AST:
|
||||
case Z3_ast_kind.Z3_NUMERAL_AST:
|
||||
case Z3_ast_kind.Z3_QUANTIFIER_AST:
|
||||
case Z3_ast_kind.Z3_VAR_AST: return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the AST is a BoundVariable
|
||||
**/
|
||||
public boolean IsVar() { return this.ASTKind == Z3_ast_kind.Z3_VAR_AST; }
|
||||
|
||||
/**
|
||||
* Indicates whether the AST is a Quantifier
|
||||
**/
|
||||
public boolean IsQuantifier() { return this.ASTKind == Z3_ast_kind.Z3_QUANTIFIER_AST; }
|
||||
|
||||
/**
|
||||
* Indicates whether the AST is a Sort
|
||||
**/
|
||||
public boolean IsSort() { return this.ASTKind == Z3_ast_kind.Z3_SORT_AST; }
|
||||
|
||||
/**
|
||||
* Indicates whether the AST is a FunctionDeclaration
|
||||
**/
|
||||
public boolean IsFuncDecl() { return this.ASTKind == Z3_ast_kind.Z3_FUNC_DECL_AST; }
|
||||
|
||||
/**
|
||||
* A string representation of the AST.
|
||||
**/
|
||||
public String toString()
|
||||
{
|
||||
return Native.asttoString(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* A string representation of the AST in s-expression notation.
|
||||
**/
|
||||
public String SExpr()
|
||||
{
|
||||
|
||||
|
||||
return Native.asttoString(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
AST(Context ctx) { super(ctx); }
|
||||
AST(Context ctx, IntPtr obj) { super(ctx, obj); }
|
||||
|
||||
class DecRefQueue extends Z3.DecRefQueue
|
||||
{
|
||||
public void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.incRef(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
public void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.decRef(ctx.nCtx, obj);
|
||||
}
|
||||
};
|
||||
|
||||
void IncRef(IntPtr o)
|
||||
{
|
||||
// Console.WriteLine("AST IncRef()");
|
||||
if (Context == null)
|
||||
throw new Z3Exception("inc() called on null context");
|
||||
if (o == IntPtr.Zero)
|
||||
throw new Z3Exception("inc() called on null AST");
|
||||
Context.AST_DRQ.IncAndClear(Context, o);
|
||||
super.IncRef(o);
|
||||
}
|
||||
|
||||
void DecRef(IntPtr o)
|
||||
{
|
||||
// Console.WriteLine("AST DecRef()");
|
||||
if (Context == null)
|
||||
throw new Z3Exception("dec() called on null context");
|
||||
if (o == IntPtr.Zero)
|
||||
throw new Z3Exception("dec() called on null AST");
|
||||
Context.AST_DRQ.Add(o);
|
||||
super.DecRef(o);
|
||||
}
|
||||
|
||||
static AST Create(Context ctx, IntPtr obj)
|
||||
{
|
||||
|
||||
|
||||
|
||||
switch ((Z3_ast_kind)Native.getAstKind(ctx.nCtx, obj))
|
||||
{
|
||||
case Z3_ast_kind.Z3_FUNC_DECL_AST: return new FuncDecl(ctx, obj);
|
||||
case Z3_ast_kind.Z3_QUANTIFIER_AST: return new Quantifier(ctx, obj);
|
||||
case Z3_ast_kind.Z3_SORT_AST: return Sort.Create(ctx, obj);
|
||||
case Z3_ast_kind.Z3_APP_AST:
|
||||
case Z3_ast_kind.Z3_NUMERAL_AST:
|
||||
case Z3_ast_kind.Z3_VAR_AST: return Expr.Create(ctx, obj);
|
||||
default:
|
||||
throw new Z3Exception("Unknown AST kind");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,127 +0,0 @@
|
|||
/**
|
||||
* This file was automatically generated from ASTMap.cs
|
||||
**/
|
||||
|
||||
package com.Microsoft.Z3;
|
||||
|
||||
/* using System; */
|
||||
|
||||
/**
|
||||
* Map from AST to AST
|
||||
**/
|
||||
class ASTMap extends Z3Object
|
||||
{
|
||||
/**
|
||||
* Checks whether the map contains the key <paramref name="k"/>.
|
||||
* <param name="k">An AST</param>
|
||||
* @return True if <paramref name="k"/> is a key in the map, false otherwise.
|
||||
**/
|
||||
public boolean Contains(AST k)
|
||||
{
|
||||
|
||||
|
||||
return Native.astMapContains(Context.nCtx, NativeObject, k.NativeObject) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the value associated with the key <paramref name="k"/>.
|
||||
* <remarks>
|
||||
* This function signs an error when <paramref name="k"/> is not a key in the map.
|
||||
* </remarks>
|
||||
* <param name="k">An AST</param>
|
||||
**/
|
||||
public AST Find(AST k)
|
||||
{
|
||||
|
||||
|
||||
|
||||
return new AST(Context, Native.astMapFind(Context.nCtx, NativeObject, k.NativeObject));
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores or replaces a new key/value pair in the map.
|
||||
* <param name="k">The key AST</param>
|
||||
* <param name="v">The value AST</param>
|
||||
**/
|
||||
public void Insert(AST k, AST v)
|
||||
{
|
||||
|
||||
|
||||
|
||||
Native.astMapInsert(Context.nCtx, NativeObject, k.NativeObject, v.NativeObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Erases the key <paramref name="k"/> from the map.
|
||||
* <param name="k">An AST</param>
|
||||
**/
|
||||
public void Erase(AST k)
|
||||
{
|
||||
|
||||
|
||||
Native.astMapErase(Context.nCtx, NativeObject, k.NativeObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all keys from the map.
|
||||
**/
|
||||
public void Reset()
|
||||
{
|
||||
Native.astMapReset(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* The size of the map
|
||||
**/
|
||||
public long Size() { return Native.astMapSize(Context.nCtx, NativeObject); }
|
||||
|
||||
/**
|
||||
* The keys stored in the map.
|
||||
**/
|
||||
public ASTVector Keys()
|
||||
{
|
||||
return new ASTVector(Context, Native.astMapKeys(Context.nCtx, NativeObject));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a string representation of the map.
|
||||
**/
|
||||
public String toString()
|
||||
{
|
||||
return Native.astMaptoString(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
ASTMap(Context ctx, IntPtr obj)
|
||||
{ super(ctx, obj);
|
||||
|
||||
}
|
||||
ASTMap(Context ctx)
|
||||
{ super(ctx, Native.mkAstMap(ctx.nCtx));
|
||||
|
||||
}
|
||||
|
||||
class DecRefQueue extends Z3.DecRefQueue
|
||||
{
|
||||
public void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.astMapIncRef(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
public void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.astMapDecRef(ctx.nCtx, obj);
|
||||
}
|
||||
};
|
||||
|
||||
void IncRef(IntPtr o)
|
||||
{
|
||||
Context.ASTMap_DRQ.IncAndClear(Context, o);
|
||||
super.IncRef(o);
|
||||
}
|
||||
|
||||
void DecRef(IntPtr o)
|
||||
{
|
||||
Context.ASTMap_DRQ.Add(o);
|
||||
super.DecRef(o);
|
||||
}
|
||||
}
|
|
@ -1,107 +0,0 @@
|
|||
/**
|
||||
* This file was automatically generated from ASTVector.cs
|
||||
**/
|
||||
|
||||
package com.Microsoft.Z3;
|
||||
|
||||
/* using System; */
|
||||
|
||||
/**
|
||||
* Vectors of ASTs.
|
||||
**/
|
||||
class ASTVector extends Z3Object
|
||||
{
|
||||
/**
|
||||
* The size of the vector
|
||||
**/
|
||||
public long Size() { return Native.astVectorSize(Context.nCtx, NativeObject); }
|
||||
|
||||
/**
|
||||
* Retrieves the i-th object in the vector.
|
||||
* <remarks>May throw an IndexOutOfBoundsException when <paramref name="i"/> is out of range.</remarks>
|
||||
* <param name="i">Index</param>
|
||||
* @return An AST
|
||||
**/
|
||||
public AST get(long i)
|
||||
{
|
||||
|
||||
|
||||
return new AST(Context, Native.astVectorGet(Context.nCtx, NativeObject, i));
|
||||
}
|
||||
public void set(long i, AST value)
|
||||
{
|
||||
|
||||
|
||||
Native.astVectorSet(Context.nCtx, NativeObject, i, value.NativeObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resize the vector to <paramref name="newSize"/>.
|
||||
* <param name="newSize">The new size of the vector.</param>
|
||||
**/
|
||||
public void Resize(long newSize)
|
||||
{
|
||||
Native.astVectorResize(Context.nCtx, NativeObject, newSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the AST <paramref name="a"/> to the back of the vector. The size
|
||||
* is increased by 1.
|
||||
* <param name="a">An AST</param>
|
||||
**/
|
||||
public void Push(AST a)
|
||||
{
|
||||
|
||||
|
||||
Native.astVectorPush(Context.nCtx, NativeObject, a.NativeObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates all ASTs in the vector to <paramref name="ctx"/>.
|
||||
* <param name="ctx">A context</param>
|
||||
* @return A new ASTVector
|
||||
**/
|
||||
public ASTVector Translate(Context ctx)
|
||||
{
|
||||
|
||||
|
||||
|
||||
return new ASTVector(Context, Native.astVectorTranslate(Context.nCtx, NativeObject, ctx.nCtx));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a string representation of the vector.
|
||||
**/
|
||||
public String toString()
|
||||
{
|
||||
return Native.astVectortoString(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
ASTVector(Context ctx, IntPtr obj) { super(ctx, obj); }
|
||||
ASTVector(Context ctx) { super(ctx, Native.mkAstVector(ctx.nCtx)); }
|
||||
|
||||
class DecRefQueue extends Z3.DecRefQueue
|
||||
{
|
||||
public void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.astVectorIncRef(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
public void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.astVectorDecRef(ctx.nCtx, obj);
|
||||
}
|
||||
};
|
||||
|
||||
void IncRef(IntPtr o)
|
||||
{
|
||||
Context.ASTVector_DRQ.IncAndClear(Context, o);
|
||||
super.IncRef(o);
|
||||
}
|
||||
|
||||
void DecRef(IntPtr o)
|
||||
{
|
||||
Context.ASTVector_DRQ.Add(o);
|
||||
super.DecRef(o);
|
||||
}
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
/**
|
||||
* This file was automatically generated from ApplyResult.cs
|
||||
**/
|
||||
|
||||
package com.Microsoft.Z3;
|
||||
|
||||
/* using System; */
|
||||
|
||||
/**
|
||||
* ApplyResult objects represent the result of an application of a
|
||||
* tactic to a goal. It contains the subgoals that were produced.
|
||||
**/
|
||||
public class ApplyResult extends Z3Object
|
||||
{
|
||||
/**
|
||||
* The number of Subgoals.
|
||||
**/
|
||||
public long NumSubgoals() { return Native.applyResultGetNumSubgoals(Context.nCtx, NativeObject); }
|
||||
|
||||
/**
|
||||
* Retrieves the subgoals from the ApplyResult.
|
||||
**/
|
||||
public Goal[] Subgoals()
|
||||
{
|
||||
|
||||
|
||||
|
||||
long n = NumSubgoals;
|
||||
Goal[] res = new Goal[n];
|
||||
for (long i = 0; i < n; i++)
|
||||
res[i] = new Goal(Context, Native.applyResultGetSubgoal(Context.nCtx, NativeObject, i));
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a model for the subgoal <paramref name="i"/> into a model for the original
|
||||
* goal <code>g</code>, that the ApplyResult was obtained from.
|
||||
* @return A model for <code>g</code>
|
||||
**/
|
||||
public Model ConvertModel(long i, Model m)
|
||||
{
|
||||
|
||||
|
||||
|
||||
return new Model(Context, Native.applyResultConvertModel(Context.nCtx, NativeObject, i, m.NativeObject));
|
||||
}
|
||||
|
||||
/**
|
||||
* A string representation of the ApplyResult.
|
||||
**/
|
||||
public String toString()
|
||||
{
|
||||
return Native.applyResulttoString(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
ApplyResult(Context ctx, IntPtr obj) { super(ctx, obj);
|
||||
|
||||
}
|
||||
|
||||
class DecRefQueue extends Z3.DecRefQueue
|
||||
{
|
||||
public void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.applyResultIncRef(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
public void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.applyResultDecRef(ctx.nCtx, obj);
|
||||
}
|
||||
};
|
||||
|
||||
void IncRef(IntPtr o)
|
||||
{
|
||||
Context.ApplyResult_DRQ.IncAndClear(Context, o);
|
||||
super.IncRef(o);
|
||||
}
|
||||
|
||||
void DecRef(IntPtr o)
|
||||
{
|
||||
Context.ApplyResult_DRQ.Add(o);
|
||||
super.DecRef(o);
|
||||
}
|
||||
}
|
|
@ -1,143 +0,0 @@
|
|||
/**
|
||||
* This file was automatically generated from Constructor.cs
|
||||
**/
|
||||
|
||||
package com.Microsoft.Z3;
|
||||
|
||||
/* using System; */
|
||||
|
||||
/**
|
||||
* Constructors are used for datatype sorts.
|
||||
**/
|
||||
public class Constructor extends Z3Object
|
||||
{
|
||||
/**
|
||||
* The number of fields of the constructor.
|
||||
**/
|
||||
public long NumFields()
|
||||
{
|
||||
init();
|
||||
return n;
|
||||
}
|
||||
|
||||
/**
|
||||
* The function declaration of the constructor.
|
||||
**/
|
||||
public FuncDecl ConstructorDecl()
|
||||
{
|
||||
|
||||
init();
|
||||
return m_constructorDecl;
|
||||
}
|
||||
|
||||
/**
|
||||
* The function declaration of the tester.
|
||||
**/
|
||||
public FuncDecl TesterDecl()
|
||||
{
|
||||
|
||||
init();
|
||||
return m_testerDecl;
|
||||
}
|
||||
|
||||
/**
|
||||
* The function declarations of the accessors
|
||||
**/
|
||||
public FuncDecl[] AccessorDecls()
|
||||
{
|
||||
|
||||
init();
|
||||
return m_accessorDecls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
**/
|
||||
protected void finalize()
|
||||
{
|
||||
Native.delConstructor(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
|
||||
private void ObjectInvariant()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private long n = 0;
|
||||
private FuncDecl m_testerDecl = null;
|
||||
private FuncDecl m_constructorDecl = null;
|
||||
private FuncDecl[] m_accessorDecls = null;
|
||||
|
||||
Constructor(Context ctx, Symbol name, Symbol recognizer, Symbol[] fieldNames,
|
||||
Sort[] sorts, long[] sortRefs)
|
||||
{ super(ctx);
|
||||
|
||||
|
||||
|
||||
|
||||
n = AST.ArrayLength(fieldNames);
|
||||
|
||||
if (n != AST.ArrayLength(sorts))
|
||||
throw new Z3Exception("Number of field names does not match number of sorts");
|
||||
if (sortRefs != null && sortRefs.Length != n)
|
||||
throw new Z3Exception("Number of field names does not match number of sort refs");
|
||||
|
||||
if (sortRefs == null) sortRefs = new long[n];
|
||||
|
||||
NativeObject = Native.mkConstructor(ctx.nCtx, name.NativeObject, recognizer.NativeObject,
|
||||
n,
|
||||
Symbol.ArrayToNative(fieldNames),
|
||||
Sort.ArrayToNative(sorts),
|
||||
sortRefs);
|
||||
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
if (m_testerDecl != null) return;
|
||||
IntPtr constructor = IntPtr.Zero;
|
||||
IntPtr tester = IntPtr.Zero;
|
||||
IntPtr[] accessors = new IntPtr[n];
|
||||
Native.queryConstructor(Context.nCtx, NativeObject, n, constructor, tester, accessors);
|
||||
m_constructorDecl = new FuncDecl(Context, constructor);
|
||||
m_testerDecl = new FuncDecl(Context, tester);
|
||||
m_accessorDecls = new FuncDecl[n];
|
||||
for (long i = 0; i < n; i++)
|
||||
m_accessorDecls[i] = new FuncDecl(Context, accessors[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists of constructors
|
||||
**/
|
||||
public class ConstructorList extends Z3Object
|
||||
{
|
||||
/**
|
||||
* Destructor.
|
||||
**/
|
||||
protected void finalize()
|
||||
{
|
||||
Native.delConstructorList(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
ConstructorList(Context ctx, IntPtr obj)
|
||||
{ super(ctx, obj);
|
||||
|
||||
}
|
||||
|
||||
ConstructorList(Context ctx, Constructor[] constructors)
|
||||
{ super(ctx);
|
||||
|
||||
|
||||
|
||||
NativeObject = Native.mkConstructorList(Context.nCtx, (long)constructors.Length, Constructor.ArrayToNative(constructors));
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue