3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-22 16:45:31 +00:00

Merge branch 'pure' of https://git01.codeplex.com/z3 into contrib

This commit is contained in:
Christoph M. Wintersteiger 2014-10-24 21:17:57 +01:00
commit 6a496a1bfb
560 changed files with 52025 additions and 9358 deletions

View file

@ -31,7 +31,7 @@ Revision History:
#include"ast_smt2_pp.h"
#include"th_rewriter.h"
#include"var_subst.h"
#include"expr_substitution.h"
#include"expr_safe_replace.h"
#include"pp.h"
#include"scoped_ctrl_c.h"
#include"cancel_eh.h"
@ -208,6 +208,7 @@ extern "C" {
MK_BINARY(Z3_mk_xor, mk_c(c)->get_basic_fid(), OP_XOR, SKIP);
MK_NARY(Z3_mk_and, mk_c(c)->get_basic_fid(), OP_AND, SKIP);
MK_NARY(Z3_mk_or, mk_c(c)->get_basic_fid(), OP_OR, SKIP);
MK_UNARY(Z3_mk_interpolant, mk_c(c)->get_basic_fid(), OP_INTERP, SKIP);
Z3_ast mk_ite_core(Z3_context c, Z3_ast t1, Z3_ast t2, Z3_ast t3) {
expr * result = mk_c(c)->m().mk_ite(to_expr(t1), to_expr(t2), to_expr(t3));
@ -786,17 +787,12 @@ extern "C" {
RETURN_Z3(of_expr(0));
}
}
expr_substitution subst(m);
expr_safe_replace subst(m);
for (unsigned i = 0; i < num_exprs; i++) {
subst.insert(from[i], to[i]);
}
th_rewriter m_rw(m);
m_rw.set_substitution(&subst);
expr_ref new_a(m);
proof_ref pr(m);
m_rw(a, new_a, pr);
subst(a, new_a);
mk_c(c)->save_ast_trail(new_a);
r = new_a.get();
RETURN_Z3(of_expr(r));
@ -927,6 +923,7 @@ extern "C" {
case OP_NOT: return Z3_OP_NOT;
case OP_IMPLIES: return Z3_OP_IMPLIES;
case OP_OEQ: return Z3_OP_OEQ;
case OP_INTERP: return Z3_OP_INTERP;
case PR_UNDEF: return Z3_OP_PR_UNDEF;
case PR_TRUE: return Z3_OP_PR_TRUE;
@ -1073,6 +1070,12 @@ extern "C" {
case OP_BSMUL_NO_OVFL:
case OP_BUMUL_NO_OVFL:
case OP_BSMUL_NO_UDFL:
case OP_BSDIV_I:
case OP_BUDIV_I:
case OP_BSREM_I:
case OP_BUREM_I:
case OP_BSMOD_I:
return Z3_OP_UNINTERPRETED;
default:
UNREACHABLE();

View file

@ -117,6 +117,7 @@ Z3_ast Z3_API NAME(Z3_context c, unsigned i, Z3_ast n) { \
Z3_sort int_s = Z3_mk_int_sort(c);
if (is_signed) {
Z3_ast r = Z3_mk_bv2int(c, n, false);
Z3_inc_ref(c, r);
Z3_sort s = Z3_get_sort(c, n);
unsigned sz = Z3_get_bv_sort_size(c, s);
rational max_bound = power(rational(2), sz);
@ -135,6 +136,7 @@ Z3_ast Z3_API NAME(Z3_context c, unsigned i, Z3_ast n) { \
Z3_dec_ref(c, pred);
Z3_dec_ref(c, sub);
Z3_dec_ref(c, zero);
Z3_dec_ref(c, r);
RETURN_Z3(res);
}
else {

View file

@ -106,10 +106,4 @@ extern "C" {
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);
// TODO
return Z3_FALSE;
}
};

View file

@ -128,6 +128,7 @@ namespace api {
for (unsigned i = 0; i < m_replay_stack.size(); ++i) {
dealloc(m_replay_stack[i]);
}
m_ast_trail.reset();
}
reset_parser();
dealloc(m_solver);
@ -139,7 +140,7 @@ namespace api {
if (m_interruptable)
(*m_interruptable)();
m().set_cancel(true);
if (m_rcf_manager.get() == 0)
if (m_rcf_manager.get() != 0)
m_rcf_manager->set_cancel(true);
}
}
@ -342,24 +343,21 @@ namespace api {
void context::push() {
get_smt_kernel().push();
if (!m_user_ref_count) {
m_ast_lim.push_back(m_ast_trail.size());
m_replay_stack.push_back(0);
}
m_ast_lim.push_back(m_ast_trail.size());
m_replay_stack.push_back(0);
}
void context::pop(unsigned num_scopes) {
for (unsigned i = 0; i < num_scopes; ++i) {
if (!m_user_ref_count) {
unsigned sz = m_ast_lim.back();
m_ast_lim.pop_back();
dealloc(m_replay_stack.back());
m_replay_stack.pop_back();
while (m_ast_trail.size() > sz) {
m_ast_trail.pop_back();
}
unsigned sz = m_ast_lim.back();
m_ast_lim.pop_back();
dealloc(m_replay_stack.back());
m_replay_stack.pop_back();
while (m_ast_trail.size() > sz) {
m_ast_trail.pop_back();
}
}
SASSERT(num_scopes <= get_smt_kernel().get_scope_level());
get_smt_kernel().pop(num_scopes);
}

View file

@ -18,7 +18,6 @@ Revision History:
#include"api_datalog.h"
#include"api_context.h"
#include"api_util.h"
#include"dl_context.h"
#include"ast_pp.h"
#include"api_ast_vector.h"
#include"api_log_macros.h"
@ -29,104 +28,126 @@ Revision History:
#include"dl_cmds.h"
#include"cmd_context.h"
#include"smt2parser.h"
#include"dl_context.h"
#include"dl_register_engine.h"
#include"dl_external_relation.h"
#include"dl_decl_plugin.h"
#include"rel_context.h"
namespace api {
fixedpoint_context::fixedpoint_context(ast_manager& m, smt_params& p) :
m_state(0),
m_reduce_app(0),
m_reduce_assign(0),
m_context(m, p),
m_trail(m) {}
void fixedpoint_context::set_state(void* state) {
SASSERT(!m_state);
m_state = state;
symbol name("datalog_relation");
ast_manager& m = m_context.get_manager();
if (!m.has_plugin(name)) {
m.register_plugin(name, alloc(datalog::dl_decl_plugin));
}
datalog::relation_manager& r = m_context.get_rel_context().get_rmanager();
r.register_plugin(alloc(datalog::external_relation_plugin, *this, r));
}
void fixedpoint_context::reduce(func_decl* f, unsigned num_args, expr * const* args, expr_ref& result) {
expr* r = 0;
if (m_reduce_app) {
m_reduce_app(m_state, f, num_args, args, &r);
result = r;
m_trail.push_back(f);
for (unsigned i = 0; i < num_args; ++i) {
m_trail.push_back(args[i]);
}
m_trail.push_back(r);
}
// allow fallthrough.
if (r == 0) {
class fixedpoint_context : public datalog::external_relation_context {
void * m_state;
reduce_app_callback_fptr m_reduce_app;
reduce_assign_callback_fptr m_reduce_assign;
datalog::register_engine m_register_engine;
datalog::context m_context;
ast_ref_vector m_trail;
public:
fixedpoint_context(ast_manager& m, smt_params& p):
m_state(0),
m_reduce_app(0),
m_reduce_assign(0),
m_context(m, m_register_engine, p),
m_trail(m) {}
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) {
SASSERT(!m_state);
m_state = state;
symbol name("datalog_relation");
ast_manager& m = m_context.get_manager();
result = m.mk_app(f, num_args, args);
}
}
// overwrite terms passed in outs vector with values computed by function.
void fixedpoint_context::reduce_assign(func_decl* f, unsigned num_args, expr * const* args, unsigned num_out, expr* const* outs) {
if (m_reduce_assign) {
m_trail.push_back(f);
for (unsigned i = 0; i < num_args; ++i) {
m_trail.push_back(args[i]);
if (!m.has_plugin(name)) {
m.register_plugin(name, alloc(datalog::dl_decl_plugin));
}
datalog::rel_context_base* rel = m_context.get_rel_context();
if (rel) {
datalog::relation_manager& r = rel->get_rmanager();
r.register_plugin(alloc(datalog::external_relation_plugin, *this, r));
}
m_reduce_assign(m_state, f, num_args, args, num_out, outs);
}
}
void fixedpoint_context::add_rule(expr* rule, symbol const& name) {
m_context.add_rule(rule, name);
}
void fixedpoint_context::update_rule(expr* rule, symbol const& name) {
m_context.update_rule(rule, name);
}
void fixedpoint_context::add_table_fact(func_decl* r, unsigned num_args, unsigned args[]) {
m_context.add_table_fact(r, num_args, args);
}
unsigned fixedpoint_context::get_num_levels(func_decl* pred) {
return m_context.get_num_levels(pred);
}
expr_ref fixedpoint_context::get_cover_delta(int level, func_decl* pred) {
return m_context.get_cover_delta(level, pred);
}
void fixedpoint_context::add_cover(int level, func_decl* pred, expr* predicate) {
m_context.add_cover(level, pred, predicate);
}
std::string fixedpoint_context::get_last_status() {
datalog::execution_result status = m_context.get_status();
switch(status) {
case datalog::INPUT_ERROR:
return "input error";
case datalog::OK:
return "ok";
case datalog::TIMEOUT:
return "timeout";
default:
UNREACHABLE();
return "unknown";
void set_reduce_app(reduce_app_callback_fptr f) {
m_reduce_app = f;
}
}
std::string fixedpoint_context::to_string(unsigned num_queries, expr*const* queries) {
std::stringstream str;
m_context.display_smt2(num_queries, queries, str);
return str.str();
}
void set_reduce_assign(reduce_assign_callback_fptr f) {
m_reduce_assign = f;
}
virtual void reduce(func_decl* f, unsigned num_args, expr * const* args, expr_ref& result) {
expr* r = 0;
if (m_reduce_app) {
m_reduce_app(m_state, f, num_args, args, &r);
result = r;
m_trail.push_back(f);
for (unsigned i = 0; i < num_args; ++i) {
m_trail.push_back(args[i]);
}
m_trail.push_back(r);
}
// allow fallthrough.
if (r == 0) {
ast_manager& m = m_context.get_manager();
result = m.mk_app(f, num_args, args);
}
}
virtual void reduce_assign(func_decl* f, unsigned num_args, expr * const* args, unsigned num_out, expr* const* outs) {
if (m_reduce_assign) {
m_trail.push_back(f);
for (unsigned i = 0; i < num_args; ++i) {
m_trail.push_back(args[i]);
}
m_reduce_assign(m_state, f, num_args, args, num_out, outs);
}
}
datalog::context& ctx() { return m_context; }
void add_rule(expr* rule, symbol const& name) {
m_context.add_rule(rule, name);
}
void update_rule(expr* rule, symbol const& name) {
m_context.update_rule(rule, name);
}
void add_table_fact(func_decl* r, unsigned num_args, unsigned args[]) {
m_context.add_table_fact(r, num_args, args);
}
std::string get_last_status() {
datalog::execution_result status = m_context.get_status();
switch(status) {
case datalog::INPUT_ERROR:
return "input error";
case datalog::OK:
return "ok";
case datalog::TIMEOUT:
return "timeout";
case datalog::APPROX:
return "approximated";
default:
UNREACHABLE();
return "unknown";
}
}
std::string to_string(unsigned num_queries, expr*const* queries) {
std::stringstream str;
m_context.display_smt2(num_queries, queries, str);
return str.str();
}
void cancel() {
m_context.cancel();
}
void reset_cancel() {
m_context.reset_cancel();
}
unsigned get_num_levels(func_decl* pred) {
return m_context.get_num_levels(pred);
}
expr_ref get_cover_delta(int level, func_decl* pred) {
return m_context.get_cover_delta(level, pred);
}
void add_cover(int level, func_decl* pred, expr* predicate) {
m_context.add_cover(level, pred, predicate);
}
void collect_param_descrs(param_descrs & p) { m_context.collect_params(p); }
void updt_params(params_ref const& p) { m_context.updt_params(p); }
};
};
extern "C" {

View file

@ -22,48 +22,14 @@ Revision History:
#include"z3.h"
#include"ast.h"
#include"smt_params.h"
#include"dl_external_relation.h"
#include"dl_decl_plugin.h"
#include"smt_kernel.h"
#include"api_util.h"
#include"dl_context.h"
typedef void (*reduce_app_callback_fptr)(void*, func_decl*, unsigned, expr*const*, expr**);
typedef void (*reduce_assign_callback_fptr)(void*, func_decl*, unsigned, expr*const*, unsigned, expr*const*);
namespace api {
class fixedpoint_context : public datalog::external_relation_context {
void * m_state;
reduce_app_callback_fptr m_reduce_app;
reduce_assign_callback_fptr m_reduce_assign;
datalog::context m_context;
ast_ref_vector m_trail;
public:
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);
void set_reduce_app(reduce_app_callback_fptr f) { m_reduce_app = f; }
void set_reduce_assign(reduce_assign_callback_fptr f) { m_reduce_assign = f; }
virtual void reduce(func_decl* f, unsigned num_args, expr * const* args, expr_ref& result);
virtual void reduce_assign(func_decl* f, unsigned num_args, expr * const* args, unsigned num_out, expr* const* outs);
datalog::context& ctx() { return m_context; }
void add_rule(expr* rule, symbol const& name);
void update_rule(expr* rule, symbol const& name);
void add_table_fact(func_decl* r, unsigned num_args, unsigned args[]);
std::string get_last_status();
std::string to_string(unsigned num_queries, expr*const* queries);
void cancel() { m_context.cancel(); }
void reset_cancel() { m_context.reset_cancel(); }
unsigned get_num_levels(func_decl* pred);
expr_ref get_cover_delta(int level, func_decl* pred);
void add_cover(int level, func_decl* pred, expr* predicate);
void collect_param_descrs(param_descrs & p) { m_context.collect_params(p); }
void updt_params(params_ref const& p) { m_context.updt_params(p); }
};
class fixedpoint_context;
};

723
src/api/api_interp.cpp Normal file
View file

@ -0,0 +1,723 @@
/*++
Copyright (c) 2011 Microsoft Corporation
Module Name:
api_interp.cpp
Abstract:
API for interpolation
Author:
Ken McMillan
Revision History:
--*/
#include<iostream>
#include<sstream>
#include<vector>
#include"z3.h"
#include"api_log_macros.h"
#include"api_context.h"
#include"api_tactic.h"
#include"api_solver.h"
#include"api_model.h"
#include"api_stats.h"
#include"api_ast_vector.h"
#include"tactic2solver.h"
#include"scoped_ctrl_c.h"
#include"cancel_eh.h"
#include"scoped_timer.h"
#include"smt_strategic_solver.h"
#include"smt_solver.h"
#include"smt_implied_equalities.h"
#include"iz3interp.h"
#include"iz3profiling.h"
#include"iz3hash.h"
#include"iz3pp.h"
#include"iz3checker.h"
#include"scoped_proof.h"
using namespace stl_ext;
// WARNING: don't make a hash_map with this if the range type
// has a destructor: you'll get an address dependency!!!
namespace stl_ext {
template <>
class hash < Z3_ast > {
public:
size_t operator()(const Z3_ast p) const {
return (size_t)p;
}
};
}
typedef interpolation_options_struct *Z3_interpolation_options;
extern "C" {
Z3_context Z3_mk_interpolation_context(Z3_config cfg){
if (!cfg) cfg = Z3_mk_config();
Z3_set_param_value(cfg, "PROOF", "true");
Z3_set_param_value(cfg, "MODEL", "true");
// Z3_set_param_value(cfg, "PRE_SIMPLIFIER","false");
// Z3_set_param_value(cfg, "SIMPLIFY_CLAUSES","false");
Z3_context ctx = Z3_mk_context(cfg);
Z3_del_config(cfg);
return ctx;
}
void Z3_interpolate_proof(Z3_context ctx,
Z3_ast proof,
int num,
Z3_ast *cnsts,
unsigned *parents,
Z3_params options,
Z3_ast *interps,
int num_theory,
Z3_ast *theory)
{
if (num > 1){ // if we have interpolants to compute
ptr_vector<ast> pre_cnsts_vec(num); // get constraints in a vector
for (int i = 0; i < num; i++){
ast *a = to_ast(cnsts[i]);
pre_cnsts_vec[i] = a;
}
::vector<int> pre_parents_vec; // get parents in a vector
if (parents){
pre_parents_vec.resize(num);
for (int i = 0; i < num; i++)
pre_parents_vec[i] = parents[i];
}
ptr_vector<ast> theory_vec; // get background theory in a vector
if (theory){
theory_vec.resize(num_theory);
for (int i = 0; i < num_theory; i++)
theory_vec[i] = to_ast(theory[i]);
}
ptr_vector<ast> interpolants(num - 1); // make space for result
ast_manager &_m = mk_c(ctx)->m();
iz3interpolate(_m,
to_ast(proof),
pre_cnsts_vec,
pre_parents_vec,
interpolants,
theory_vec,
0); // ignore params for now FIXME
// copy result back
for (unsigned i = 0; i < interpolants.size(); i++){
mk_c(ctx)->save_ast_trail(interpolants[i]);
interps[i] = of_ast(interpolants[i]);
_m.dec_ref(interpolants[i]);
}
}
}
static std::ostringstream itp_err;
int Z3_check_interpolant(Z3_context ctx,
unsigned num,
Z3_ast *cnsts,
unsigned *parents,
Z3_ast *itp,
Z3_string *error,
unsigned num_theory,
Z3_ast *theory){
ast_manager &_m = mk_c(ctx)->m();
itp_err.clear();
// need a solver -- make one here, but how?
params_ref p = params_ref::get_empty(); //FIXME
scoped_ptr<solver_factory> sf(mk_smt_solver_factory());
scoped_ptr<solver> sp((*(sf))(_m, p, false, true, false, symbol("AUFLIA")));
ptr_vector<ast> cnsts_vec(num); // get constraints in a vector
for (unsigned i = 0; i < num; i++){
ast *a = to_ast(cnsts[i]);
cnsts_vec[i] = a;
}
ptr_vector<ast> itp_vec(num); // get interpolants in a vector
for (unsigned i = 0; i < num - 1; i++){
ast *a = to_ast(itp[i]);
itp_vec[i] = a;
}
::vector<int> parents_vec; // get parents in a vector
if (parents){
parents_vec.resize(num);
for (unsigned i = 0; i < num; i++)
parents_vec[i] = parents[i];
}
ptr_vector<ast> theory_vec; // get background theory in a vector
if (theory){
theory_vec.resize(num_theory);
for (unsigned i = 0; i < num_theory; i++)
theory_vec[i] = to_ast(theory[i]);
}
bool res = iz3check(_m,
sp.get(),
itp_err,
cnsts_vec,
parents_vec,
itp_vec,
theory_vec);
*error = res ? 0 : itp_err.str().c_str();
return res;
}
static std::string Z3_profile_string;
Z3_string Z3_interpolation_profile(Z3_context ctx){
std::ostringstream f;
profiling::print(f);
Z3_profile_string = f.str();
return Z3_profile_string.c_str();
}
Z3_interpolation_options
Z3_mk_interpolation_options(){
return (Z3_interpolation_options) new interpolation_options_struct;
}
void
Z3_del_interpolation_options(Z3_interpolation_options opts){
delete opts;
}
void
Z3_set_interpolation_option(Z3_interpolation_options opts,
Z3_string name,
Z3_string value){
opts->map[name] = value;
}
Z3_ast_vector Z3_API Z3_get_interpolant(__in Z3_context c, __in Z3_ast pf, __in Z3_ast pat, __in Z3_params p){
Z3_TRY;
LOG_Z3_get_interpolant(c, pf, pat, p);
RESET_ERROR_CODE();
Z3_ast_vector_ref * v = alloc(Z3_ast_vector_ref, mk_c(c)->m());
mk_c(c)->save_object(v);
ast *_pf = to_ast(pf);
ast *_pat = to_ast(pat);
ptr_vector<ast> interp;
ptr_vector<ast> cnsts; // to throw away
ast_manager &_m = mk_c(c)->m();
iz3interpolate(_m,
_pf,
cnsts,
_pat,
interp,
(interpolation_options_struct *)0 // ignore params for now
);
// copy result back
for (unsigned i = 0; i < interp.size(); i++){
v->m_ast_vector.push_back(interp[i]);
_m.dec_ref(interp[i]);
}
RETURN_Z3(of_ast_vector(v));
Z3_CATCH_RETURN(0);
}
Z3_lbool Z3_API Z3_compute_interpolant(__in Z3_context c, __in Z3_ast pat, __in Z3_params p, __out Z3_ast_vector *out_interp, __out Z3_model *model){
Z3_TRY;
LOG_Z3_compute_interpolant(c, pat, p, out_interp, model);
RESET_ERROR_CODE();
// params_ref &_p = to_params(p)->m_params;
params_ref _p;
_p.set_bool("proof", true); // this is currently useless
scoped_proof_mode spm(mk_c(c)->m(), PGM_FINE);
scoped_ptr<solver_factory> sf = mk_smt_solver_factory();
scoped_ptr<solver> m_solver((*sf)(mk_c(c)->m(), _p, true, true, true, ::symbol::null));
m_solver.get()->updt_params(_p); // why do we have to do this?
ast *_pat = to_ast(pat);
ptr_vector<ast> interp;
ptr_vector<ast> cnsts; // to throw away
ast_manager &_m = mk_c(c)->m();
model_ref m;
lbool _status = iz3interpolate(_m,
*(m_solver.get()),
_pat,
cnsts,
interp,
m,
0 // ignore params for now
);
for (unsigned i = 0; i < cnsts.size(); i++)
_m.dec_ref(cnsts[i]);
Z3_lbool status = of_lbool(_status);
Z3_ast_vector_ref *v = 0;
*model = 0;
if (_status == l_false){
// copy result back
v = alloc(Z3_ast_vector_ref, mk_c(c)->m());
mk_c(c)->save_object(v);
for (unsigned i = 0; i < interp.size(); i++){
v->m_ast_vector.push_back(interp[i]);
_m.dec_ref(interp[i]);
}
}
else {
model_ref _m;
m_solver.get()->get_model(_m);
Z3_model_ref *crap = alloc(Z3_model_ref);
crap->m_model = _m.get();
mk_c(c)->save_object(crap);
*model = of_model(crap);
}
*out_interp = of_ast_vector(v);
return status;
Z3_CATCH_RETURN(Z3_L_UNDEF);
}
};
static void tokenize(const std::string &str, std::vector<std::string> &tokens){
for (unsigned i = 0; i < str.size();){
if (str[i] == ' '){ i++; continue; }
unsigned beg = i;
while (i < str.size() && str[i] != ' ')i++;
if (i > beg)
tokens.push_back(str.substr(beg, i - beg));
}
}
static void get_file_params(const char *filename, hash_map<std::string, std::string> &params){
std::ifstream f(filename);
if (f){
std::string first_line;
std::getline(f, first_line);
// std::cout << "first line: '" << first_line << "'" << std::endl;
if (first_line.size() >= 2 && first_line[0] == ';' && first_line[1] == '!'){
std::vector<std::string> tokens;
tokenize(first_line.substr(2, first_line.size() - 2), tokens);
for (unsigned i = 0; i < tokens.size(); i++){
std::string &tok = tokens[i];
size_t eqpos = tok.find('=');
if (eqpos != std::string::npos){
std::string left = tok.substr(0, eqpos);
std::string right = tok.substr(eqpos + 1, tok.size() - eqpos - 1);
params[left] = right;
}
}
}
f.close();
}
}
extern "C" {
#if 0
static void iZ3_write_seq(Z3_context ctx, int num, Z3_ast *cnsts, const char *filename, int num_theory, Z3_ast *theory){
int num_fmlas = num+num_theory;
std::vector<Z3_ast> fmlas(num_fmlas);
if(num_theory)
std::copy(theory,theory+num_theory,fmlas.begin());
for(int i = 0; i < num_theory; i++)
fmlas[i] = Z3_mk_implies(ctx,Z3_mk_true(ctx),fmlas[i]);
std::copy(cnsts,cnsts+num,fmlas.begin()+num_theory);
Z3_string smt = Z3_benchmark_to_smtlib_string(ctx,"none","AUFLIA","unknown","",num_fmlas-1,&fmlas[0],fmlas[num_fmlas-1]);
std::ofstream f(filename);
if(num_theory)
f << ";! THEORY=" << num_theory << "\n";
f << smt;
f.close();
}
void Z3_write_interpolation_problem(Z3_context ctx, int num, Z3_ast *cnsts, unsigned *parents, const char *filename, int num_theory, Z3_ast *theory){
if(!parents){
iZ3_write_seq(ctx,num,cnsts,filename,num_theory,theory);
return;
}
std::vector<Z3_ast> tcnsts(num);
hash_map<int,Z3_ast> syms;
for(int j = 0; j < num - 1; j++){
std::ostringstream oss;
oss << "$P" << j;
std::string name = oss.str();
Z3_symbol s = Z3_mk_string_symbol(ctx, name.c_str());
Z3_ast symbol = Z3_mk_const(ctx, s, Z3_mk_bool_sort(ctx));
syms[j] = symbol;
tcnsts[j] = Z3_mk_implies(ctx,cnsts[j],symbol);
}
tcnsts[num-1] = Z3_mk_implies(ctx,cnsts[num-1],Z3_mk_false(ctx));
for(int j = num-2; j >= 0; j--){
int parent = parents[j];
// assert(parent >= 0 && parent < num);
tcnsts[parent] = Z3_mk_implies(ctx,syms[j],tcnsts[parent]);
}
iZ3_write_seq(ctx,num,&tcnsts[0],filename,num_theory,theory);
}
#else
static Z3_ast and_vec(Z3_context ctx, svector<Z3_ast> &c){
return (c.size() > 1) ? Z3_mk_and(ctx, c.size(), &c[0]) : c[0];
}
static Z3_ast parents_vector_to_tree(Z3_context ctx, int num, Z3_ast *cnsts, unsigned *parents){
Z3_ast res;
if (!parents){
res = Z3_mk_interpolant(ctx, cnsts[0]);
for (int i = 1; i < num - 1; i++){
Z3_ast bar[2] = { res, cnsts[i] };
res = Z3_mk_interpolant(ctx, Z3_mk_and(ctx, 2, bar));
}
if (num > 1){
Z3_ast bar[2] = { res, cnsts[num - 1] };
res = Z3_mk_and(ctx, 2, bar);
}
}
else {
std::vector<svector<Z3_ast> > chs(num);
for (int i = 0; i < num - 1; i++){
svector<Z3_ast> &c = chs[i];
c.push_back(cnsts[i]);
Z3_ast foo = Z3_mk_interpolant(ctx, and_vec(ctx, c));
chs[parents[i]].push_back(foo);
}
{
svector<Z3_ast> &c = chs[num - 1];
c.push_back(cnsts[num - 1]);
res = and_vec(ctx, c);
}
}
Z3_inc_ref(ctx, res);
return res;
}
void Z3_write_interpolation_problem(Z3_context ctx, unsigned num, Z3_ast *cnsts, unsigned *parents, const char *filename, unsigned num_theory, Z3_ast *theory){
std::ofstream f(filename);
if (num > 0){
#if 0
// Suggested shorthand:
ptr_vector<expr> cnsts_vec;
cnsts_vec.append(num, to_exprs(cnsts));
cnsts_vec.append(num_theory, to_exprs(theory));
#endif
ptr_vector<expr> cnsts_vec(num); // get constraints in a vector
for (unsigned i = 0; i < num; i++){
expr *a = to_expr(cnsts[i]);
cnsts_vec[i] = a;
}
for (unsigned i = 0; i < num_theory; i++){
expr *a = to_expr(theory[i]);
cnsts_vec.push_back(a);
}
Z3_ast tree = parents_vector_to_tree(ctx, num, cnsts, parents);
iz3pp(mk_c(ctx)->m(), cnsts_vec, to_expr(tree), f);
Z3_dec_ref(ctx, tree);
}
f.close();
#if 0
if(!parents){
iZ3_write_seq(ctx,num,cnsts,filename,num_theory,theory);
return;
}
std::vector<Z3_ast> tcnsts(num);
hash_map<int,Z3_ast> syms;
for(int j = 0; j < num - 1; j++){
std::ostringstream oss;
oss << "$P" << j;
std::string name = oss.str();
Z3_symbol s = Z3_mk_string_symbol(ctx, name.c_str());
Z3_ast symbol = Z3_mk_const(ctx, s, Z3_mk_bool_sort(ctx));
syms[j] = symbol;
tcnsts[j] = Z3_mk_implies(ctx,cnsts[j],symbol);
}
tcnsts[num-1] = Z3_mk_implies(ctx,cnsts[num-1],Z3_mk_false(ctx));
for(int j = num-2; j >= 0; j--){
int parent = parents[j];
// assert(parent >= 0 && parent < num);
tcnsts[parent] = Z3_mk_implies(ctx,syms[j],tcnsts[parent]);
}
iZ3_write_seq(ctx,num,&tcnsts[0],filename,num_theory,theory);
#endif
}
#endif
static std::vector<Z3_ast> read_cnsts;
static std::vector<unsigned> read_parents;
static std::ostringstream read_error;
static std::string read_msg;
static std::vector<Z3_ast> read_theory;
static bool iZ3_parse(Z3_context ctx, const char *filename, const char **error, svector<Z3_ast> &assertions){
read_error.clear();
try {
std::string foo(filename);
if (foo.size() >= 5 && foo.substr(foo.size() - 5) == ".smt2"){
Z3_ast ass = Z3_parse_smtlib2_file(ctx, filename, 0, 0, 0, 0, 0, 0);
Z3_app app = Z3_to_app(ctx, ass);
int nconjs = Z3_get_app_num_args(ctx, app);
assertions.resize(nconjs);
for (int k = 0; k < nconjs; k++)
assertions[k] = Z3_get_app_arg(ctx, app, k);
}
else {
Z3_parse_smtlib_file(ctx, filename, 0, 0, 0, 0, 0, 0);
int numa = Z3_get_smtlib_num_assumptions(ctx);
int numf = Z3_get_smtlib_num_formulas(ctx);
int num = numa + numf;
assertions.resize(num);
for (int j = 0; j < num; j++){
if (j < numa)
assertions[j] = Z3_get_smtlib_assumption(ctx, j);
else
assertions[j] = Z3_get_smtlib_formula(ctx, j - numa);
}
}
}
catch (...) {
read_error << "SMTLIB parse error: " << Z3_get_smtlib_error(ctx);
read_msg = read_error.str();
*error = read_msg.c_str();
return false;
}
Z3_set_error_handler(ctx, 0);
return true;
}
int Z3_read_interpolation_problem(Z3_context ctx, unsigned *_num, Z3_ast *cnsts[], unsigned *parents[], const char *filename, Z3_string_ptr error, unsigned *ret_num_theory, Z3_ast *theory[]){
hash_map<std::string, std::string> file_params;
get_file_params(filename, file_params);
unsigned num_theory = 0;
if (file_params.find("THEORY") != file_params.end())
num_theory = atoi(file_params["THEORY"].c_str());
svector<Z3_ast> assertions;
if (!iZ3_parse(ctx, filename, error, assertions))
return false;
if (num_theory > assertions.size())
num_theory = assertions.size();
unsigned num = assertions.size() - num_theory;
read_cnsts.resize(num);
read_parents.resize(num);
read_theory.resize(num_theory);
for (unsigned j = 0; j < num_theory; j++)
read_theory[j] = assertions[j];
for (unsigned j = 0; j < num; j++)
read_cnsts[j] = assertions[j + num_theory];
if (ret_num_theory)
*ret_num_theory = num_theory;
if (theory)
*theory = &read_theory[0];
if (!parents){
*_num = num;
*cnsts = &read_cnsts[0];
return true;
}
for (unsigned j = 0; j < num; j++)
read_parents[j] = SHRT_MAX;
hash_map<Z3_ast, int> pred_map;
for (unsigned j = 0; j < num; j++){
Z3_ast lhs = 0, rhs = read_cnsts[j];
if (Z3_get_decl_kind(ctx, Z3_get_app_decl(ctx, Z3_to_app(ctx, rhs))) == Z3_OP_IMPLIES){
Z3_app app1 = Z3_to_app(ctx, rhs);
Z3_ast lhs1 = Z3_get_app_arg(ctx, app1, 0);
Z3_ast rhs1 = Z3_get_app_arg(ctx, app1, 1);
if (Z3_get_decl_kind(ctx, Z3_get_app_decl(ctx, Z3_to_app(ctx, lhs1))) == Z3_OP_AND){
Z3_app app2 = Z3_to_app(ctx, lhs1);
int nconjs = Z3_get_app_num_args(ctx, app2);
for (int k = nconjs - 1; k >= 0; --k)
rhs1 = Z3_mk_implies(ctx, Z3_get_app_arg(ctx, app2, k), rhs1);
rhs = rhs1;
}
}
while (1){
Z3_app app = Z3_to_app(ctx, rhs);
Z3_func_decl func = Z3_get_app_decl(ctx, app);
Z3_decl_kind dk = Z3_get_decl_kind(ctx, func);
if (dk == Z3_OP_IMPLIES){
if (lhs){
Z3_ast child = lhs;
if (pred_map.find(child) == pred_map.end()){
read_error << "formula " << j + 1 << ": unknown: " << Z3_ast_to_string(ctx, child);
goto fail;
}
int child_num = pred_map[child];
if (read_parents[child_num] != SHRT_MAX){
read_error << "formula " << j + 1 << ": multiple reference: " << Z3_ast_to_string(ctx, child);
goto fail;
}
read_parents[child_num] = j;
}
lhs = Z3_get_app_arg(ctx, app, 0);
rhs = Z3_get_app_arg(ctx, app, 1);
}
else {
if (!lhs){
read_error << "formula " << j + 1 << ": should be (implies {children} fmla parent)";
goto fail;
}
read_cnsts[j] = lhs;
Z3_ast name = rhs;
if (pred_map.find(name) != pred_map.end()){
read_error << "formula " << j + 1 << ": duplicate symbol";
goto fail;
}
pred_map[name] = j;
break;
}
}
}
for (unsigned j = 0; j < num - 1; j++)
if (read_parents[j] == SHRT_MAX){
read_error << "formula " << j + 1 << ": unreferenced";
goto fail;
}
*_num = num;
*cnsts = &read_cnsts[0];
*parents = &read_parents[0];
return true;
fail:
read_msg = read_error.str();
*error = read_msg.c_str();
return false;
}
}
#if 0
/** Constant reprepresenting a root of a formula tree for tree interpolation */
#define IZ3_ROOT SHRT_MAX
/** This function uses Z3 to determine satisfiability of a set of
constraints. If UNSAT, an interpolant is returned, based on the
refutation generated by Z3. If SAT, a model is returned.
If "parents" is non-null, computes a tree interpolant. The tree is
defined by the array "parents". This array maps each formula in
the tree to its parent, where formulas are indicated by their
integer index in "cnsts". The parent of formula n must have index
greater than n. The last formula is the root of the tree. Its
parent entry should be the constant IZ3_ROOT.
If "parents" is null, computes a sequence interpolant.
\param ctx The Z3 context. Must be generated by iz3_mk_context
\param num The number of constraints in the sequence
\param cnsts Array of constraints (AST's in context ctx)
\param parents The parents vector defining the tree structure
\param options Interpolation options (may be NULL)
\param interps Array to return interpolants (size at least num-1, may be NULL)
\param model Returns a Z3 model if constraints SAT (may be NULL)
\param labels Returns relevant labels if SAT (may be NULL)
\param incremental
VERY IMPORTANT: All the Z3 formulas in cnsts must be in Z3
context ctx. The model and interpolants returned are also
in this context.
The return code is as in Z3_check_assumptions, that is,
Z3_L_FALSE = constraints UNSAT (interpolants returned)
Z3_L_TRUE = constraints SAT (model returned)
Z3_L_UNDEF = Z3 produced no result, or interpolation not possible
Currently, this function supports integer and boolean variables,
as well as arrays over these types, with linear arithmetic,
uninterpreted functions and quantifiers over integers (that is
AUFLIA). Interpolants are produced in AULIA. However, some
uses of array operations may cause quantifiers to appear in the
interpolants even when there are no quantifiers in the input formulas.
Although quantifiers may appear in the input formulas, Z3 may give up in
this case, returning Z3_L_UNDEF.
If "incremental" is true, cnsts must contain exactly the set of
formulas that are currently asserted in the context. If false,
there must be no formulas currently asserted in the context.
Setting "incremental" to true makes it posisble to incrementally
add and remove constraints from the context until the context
becomes UNSAT, at which point an interpolant is computed. Caution
must be used, however. Before popping the context, if you wish to
keep the interolant formulas, you *must* preserve them by using
Z3_persist_ast. Also, if you want to simplify the interpolant
formulas using Z3_simplify, you must first pop all of the
assertions in the context (or use a different context). Otherwise,
the formulas will be simplified *relative* to these constraints,
which is almost certainly not what you want.
Current limitations on tree interpolants. In a tree interpolation
problem, each constant (0-ary function symbol) must occur only
along one path from root to leaf. Function symbols (of arity > 0)
are considered to have global scope (i.e., may appear in any
interpolant formula).
def_API('Z3_interpolate', BOOL, (_in(CONTEXT), _in(UINT), _in_array(1, AST), _in_array(1, UINT), _in(PARAMS), _out_array(1, AST), _out(MODEL), _out(LITERALS), _in(UINT), _in(UINT), _in_array(9, AST)))
*/
Z3_lbool Z3_API Z3_interpolate(__in Z3_context ctx,
__in unsigned num,
__in_ecount(num) Z3_ast *cnsts,
__in_ecount(num) unsigned *parents,
__in Z3_params options,
__out_ecount(num - 1) Z3_ast *interps,
__out Z3_model *model,
__out Z3_literals *labels,
__in unsigned incremental,
__in unsigned num_theory,
__in_ecount(num_theory) Z3_ast *theory);
#endif

View file

@ -60,6 +60,7 @@ extern "C" {
SET_ERROR_CODE(Z3_INVALID_ARG);
RETURN_Z3(0);
}
mk_c(c)->save_ast_trail(r);
RETURN_Z3(of_expr(r));
Z3_CATCH_RETURN(0);
}
@ -275,6 +276,7 @@ extern "C" {
RESET_ERROR_CODE();
CHECK_NON_NULL(f, 0);
expr * e = to_func_interp_ref(f)->get_else();
mk_c(c)->save_ast_trail(e);
RETURN_Z3(of_expr(e));
Z3_CATCH_RETURN(0);
}
@ -313,6 +315,7 @@ extern "C" {
LOG_Z3_func_entry_get_value(c, e);
RESET_ERROR_CODE();
expr * v = to_func_entry_ref(e)->get_result();
mk_c(c)->save_ast_trail(v);
RETURN_Z3(of_expr(v));
Z3_CATCH_RETURN(0);
}

View file

@ -165,7 +165,10 @@ extern "C" {
}
for (unsigned i = 0; i < num_bound; ++i) {
app* a = to_app(bound[i]);
SASSERT(a->get_kind() == AST_APP);
if (a->get_kind() != AST_APP) {
SET_ERROR_CODE(Z3_INVALID_ARG);
RETURN_Z3(0);
}
symbol s(to_app(a)->get_decl()->get_name());
names.push_back(of_symbol(s));
types.push_back(of_sort(mk_c(c)->m().get_sort(a)));

View file

@ -40,6 +40,12 @@ extern "C" {
params_ref p = s->m_params;
mk_c(c)->params().get_solver_params(mk_c(c)->m(), p, proofs_enabled, models_enabled, unsat_core_enabled);
s->m_solver = (*(s->m_solver_factory))(mk_c(c)->m(), p, proofs_enabled, models_enabled, unsat_core_enabled, s->m_logic);
param_descrs r;
s->m_solver->collect_param_descrs(r);
context_params::collect_solver_param_descrs(r);
p.validate(r);
s->m_solver->updt_params(p);
}
static void init_solver(Z3_context c, Z3_solver s) {
@ -101,6 +107,7 @@ extern "C" {
if (!initialized)
init_solver(c, s);
to_solver_ref(s)->collect_param_descrs(descrs);
context_params::collect_solver_param_descrs(descrs);
if (!initialized)
to_solver(s)->m_solver = 0;
descrs.display(buffer);
@ -118,6 +125,7 @@ extern "C" {
if (!initialized)
init_solver(c, s);
to_solver_ref(s)->collect_param_descrs(d->m_descrs);
context_params::collect_solver_param_descrs(d->m_descrs);
if (!initialized)
to_solver(s)->m_solver = 0;
Z3_param_descrs r = of_param_descrs(d);
@ -129,14 +137,19 @@ extern "C" {
Z3_TRY;
LOG_Z3_solver_set_params(c, s, p);
RESET_ERROR_CODE();
if (to_solver(s)->m_solver) {
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);
param_descrs r;
to_solver_ref(s)->collect_param_descrs(r);
context_params::collect_solver_param_descrs(r);
to_param_ref(p).validate(r);
to_solver_ref(s)->updt_params(to_param_ref(p));
}
to_solver(s)->m_params = to_param_ref(p);
to_solver(s)->m_params.append(to_param_ref(p));
Z3_CATCH;
}

View file

@ -40,7 +40,7 @@ extern "C" {
LOG_Z3_pop(c, num_scopes);
RESET_ERROR_CODE();
CHECK_SEARCHING(c);
if (num_scopes > mk_c(c)->get_smt_kernel().get_scope_level()) {
if (num_scopes > mk_c(c)->get_num_scopes()) {
SET_ERROR_CODE(Z3_IOB);
return;
}

View file

@ -222,6 +222,9 @@ extern "C" {
Z3_TRY;
LOG_Z3_tactic_using_params(c, t, p);
RESET_ERROR_CODE();
param_descrs r;
to_tactic_ref(t)->collect_param_descrs(r);
to_param_ref(p).validate(r);
tactic * new_t = using_params(to_tactic_ref(t), to_param_ref(p));
RETURN_TACTIC(new_t);
Z3_CATCH_RETURN(0);
@ -447,6 +450,9 @@ extern "C" {
Z3_TRY;
LOG_Z3_tactic_apply_ex(c, t, g, p);
RESET_ERROR_CODE();
param_descrs pd;
to_tactic_ref(t)->collect_param_descrs(pd);
to_param_ref(p).validate(pd);
Z3_apply_result r = _tactic_apply(c, t, g, to_param_ref(p));
RETURN_Z3(r);
Z3_CATCH_RETURN(0);

View file

@ -85,6 +85,8 @@ namespace z3 {
friend std::ostream & operator<<(std::ostream & out, exception const & e) { out << e.msg(); return out; }
};
/**
\brief Z3 global configuration object.
*/
@ -204,6 +206,8 @@ namespace z3 {
func_decl function(symbol const & name, unsigned arity, sort const * domain, sort const & range);
func_decl function(char const * name, unsigned arity, sort const * domain, sort const & range);
func_decl function(symbol const& name, sort_vector const& domain, sort const& range);
func_decl function(char const * name, sort_vector const& domain, sort const& range);
func_decl function(char const * name, sort const & domain, sort const & range);
func_decl function(char const * name, sort const & d1, sort const & d2, sort const & range);
func_decl function(char const * name, sort const & d1, sort const & d2, sort const & d3, sort const & range);
@ -267,8 +271,9 @@ namespace z3 {
object(object const & s):m_ctx(s.m_ctx) {}
context & ctx() const { return *m_ctx; }
void check_error() const { m_ctx->check_error(); }
friend void check_context(object const & a, object const & b) { assert(a.m_ctx == b.m_ctx); }
friend void check_context(object const & a, object const & b);
};
inline void check_context(object const & a, object const & b) { assert(a.m_ctx == b.m_ctx); }
class symbol : public object {
Z3_symbol m_sym;
@ -280,7 +285,7 @@ namespace z3 {
Z3_symbol_kind kind() const { return Z3_get_symbol_kind(ctx(), m_sym); }
std::string str() const { assert(kind() == Z3_STRING_SYMBOL); return Z3_get_symbol_string(ctx(), m_sym); }
int to_int() const { assert(kind() == Z3_INT_SYMBOL); return Z3_get_symbol_int(ctx(), m_sym); }
friend std::ostream & operator<<(std::ostream & out, symbol const & s) {
friend std::ostream & operator<<(std::ostream & out, symbol const & s) {
if (s.kind() == Z3_INT_SYMBOL)
out << "k!" << s.to_int();
else
@ -289,6 +294,7 @@ namespace z3 {
}
};
class params : public object {
Z3_params m_params;
public:
@ -307,7 +313,9 @@ namespace z3 {
void set(char const * k, unsigned n) { Z3_params_set_uint(ctx(), m_params, ctx().str_symbol(k), n); }
void set(char const * k, double n) { Z3_params_set_double(ctx(), m_params, ctx().str_symbol(k), n); }
void set(char const * k, symbol const & s) { Z3_params_set_symbol(ctx(), m_params, ctx().str_symbol(k), s); }
friend std::ostream & operator<<(std::ostream & out, params const & p) { out << Z3_params_to_string(p.ctx(), p); return out; }
friend std::ostream & operator<<(std::ostream & out, params const & p) {
out << Z3_params_to_string(p.ctx(), p); return out;
}
};
class ast : public object {
@ -323,14 +331,19 @@ namespace z3 {
ast & operator=(ast const & s) { Z3_inc_ref(s.ctx(), s.m_ast); if (m_ast) Z3_dec_ref(ctx(), m_ast); m_ctx = s.m_ctx; m_ast = s.m_ast; return *this; }
Z3_ast_kind kind() const { Z3_ast_kind r = Z3_get_ast_kind(ctx(), m_ast); check_error(); return r; }
unsigned hash() const { unsigned r = Z3_get_ast_hash(ctx(), m_ast); check_error(); return r; }
friend std::ostream & operator<<(std::ostream & out, ast const & n) { out << Z3_ast_to_string(n.ctx(), n.m_ast); return out; }
friend std::ostream & operator<<(std::ostream & out, ast const & n) {
out << Z3_ast_to_string(n.ctx(), n.m_ast); return out;
}
/**
\brief Return true if the ASTs are structurally identical.
*/
friend bool eq(ast const & a, ast const & b) { return Z3_is_eq_ast(a.ctx(), a, b) != 0; }
friend bool eq(ast const & a, ast const & b);
};
inline bool eq(ast const & a, ast const & b) { return Z3_is_eq_ast(a.ctx(), a, b) != 0; }
/**
\brief A Z3 sort (aka type). Every expression (i.e., formula or term) in Z3 has a sort.
*/
@ -429,6 +442,7 @@ namespace z3 {
expr operator()() const;
expr operator()(unsigned n, expr const * args) const;
expr operator()(expr_vector const& v) const;
expr operator()(expr const & a) const;
expr operator()(int a) const;
expr operator()(expr const & a1, expr const & a2) const;
@ -567,6 +581,7 @@ namespace z3 {
return expr(a.ctx(), r);
}
/**
\brief Return an expression representing <tt>a and b</tt>.
@ -582,6 +597,7 @@ namespace z3 {
return expr(a.ctx(), r);
}
/**
\brief Return an expression representing <tt>a and b</tt>.
The C++ Boolean value \c b is automatically converted into a Z3 Boolean constant.
@ -633,21 +649,12 @@ namespace z3 {
a.check_error();
return expr(a.ctx(), r);
}
friend expr implies(expr const & a, bool b) { return implies(a, a.ctx().bool_val(b)); }
friend expr implies(bool a, expr const & b) { return implies(b.ctx().bool_val(a), b); }
friend expr implies(expr const & a, bool b);
friend expr implies(bool a, expr const & b);
/**
\brief Create the if-then-else expression <tt>ite(c, t, e)</tt>
\pre c.is_bool()
*/
friend expr ite(expr const & c, expr const & t, expr const & e) {
check_context(c, t); check_context(c, e);
assert(c.is_bool());
Z3_ast r = Z3_mk_ite(c.ctx(), c, t, e);
c.check_error();
return expr(c.ctx(), r);
}
friend expr ite(expr const & c, expr const & t, expr const & e);
friend expr distinct(expr_vector const& args);
friend expr operator==(expr const & a, expr const & b) {
check_context(a, b);
@ -711,15 +718,9 @@ namespace z3 {
/**
\brief Power operator
*/
friend expr pw(expr const & a, expr const & b) {
assert(a.is_arith() && b.is_arith());
check_context(a, b);
Z3_ast r = Z3_mk_power(a.ctx(), a, b);
a.check_error();
return expr(a.ctx(), r);
}
friend expr pw(expr const & a, int b) { return pw(a, a.ctx().num_val(b, a.get_sort())); }
friend expr pw(int a, expr const & b) { return pw(b.ctx().num_val(a, b.get_sort()), b); }
friend expr pw(expr const & a, expr const & b);
friend expr pw(expr const & a, int b);
friend expr pw(int a, expr const & b);
friend expr operator/(expr const & a, expr const & b) {
check_context(a, b);
@ -886,6 +887,38 @@ namespace z3 {
expr substitute(expr_vector const& dst);
};
inline expr implies(expr const & a, bool b) { return implies(a, a.ctx().bool_val(b)); }
inline expr implies(bool a, expr const & b) { return implies(b.ctx().bool_val(a), b); }
inline expr pw(expr const & a, expr const & b) {
assert(a.is_arith() && b.is_arith());
check_context(a, b);
Z3_ast r = Z3_mk_power(a.ctx(), a, b);
a.check_error();
return expr(a.ctx(), r);
}
inline expr pw(expr const & a, int b) { return pw(a, a.ctx().num_val(b, a.get_sort())); }
inline expr pw(int a, expr const & b) { return pw(b.ctx().num_val(a, b.get_sort()), b); }
/**
\brief Create the if-then-else expression <tt>ite(c, t, e)</tt>
\pre c.is_bool()
*/
inline expr ite(expr const & c, expr const & t, expr const & e) {
check_context(c, t); check_context(c, e);
assert(c.is_bool());
Z3_ast r = Z3_mk_ite(c.ctx(), c, t, e);
c.check_error();
return expr(c.ctx(), r);
}
/**
\brief Wraps a Z3_ast as an expr object. It also checks for errors.
@ -1062,6 +1095,16 @@ namespace z3 {
array<Z3_app> vars(xs);
Z3_ast r = Z3_mk_exists_const(b.ctx(), 0, vars.size(), vars.ptr(), 0, 0, b); b.check_error(); return expr(b.ctx(), r);
}
inline expr distinct(expr_vector const& args) {
assert(args.size() > 0);
context& ctx = args[0].ctx();
array<Z3_ast> _args(args);
Z3_ast r = Z3_mk_distinct(ctx, _args.size(), _args.ptr());
ctx.check_error();
return expr(ctx, r);
}
class func_entry : public object {
Z3_func_entry m_entry;
@ -1305,7 +1348,7 @@ namespace z3 {
expr as_expr() const {
unsigned n = size();
if (n == 0)
return ctx().bool_val(false);
return ctx().bool_val(true);
else if (n == 1)
return operator[](0);
else {
@ -1389,22 +1432,28 @@ namespace z3 {
t1.check_error();
return tactic(t1.ctx(), r);
}
friend tactic repeat(tactic const & t, unsigned max=UINT_MAX) {
Z3_tactic r = Z3_tactic_repeat(t.ctx(), t, max);
t.check_error();
return tactic(t.ctx(), r);
}
friend tactic with(tactic const & t, params const & p) {
Z3_tactic r = Z3_tactic_using_params(t.ctx(), t, p);
t.check_error();
return tactic(t.ctx(), r);
}
friend tactic try_for(tactic const & t, unsigned ms) {
Z3_tactic r = Z3_tactic_try_for(t.ctx(), t, ms);
t.check_error();
return tactic(t.ctx(), r);
}
friend tactic repeat(tactic const & t, unsigned max);
friend tactic with(tactic const & t, params const & p);
friend tactic try_for(tactic const & t, unsigned ms);
};
inline tactic repeat(tactic const & t, unsigned max=UINT_MAX) {
Z3_tactic r = Z3_tactic_repeat(t.ctx(), t, max);
t.check_error();
return tactic(t.ctx(), r);
}
inline tactic with(tactic const & t, params const & p) {
Z3_tactic r = Z3_tactic_using_params(t.ctx(), t, p);
t.check_error();
return tactic(t.ctx(), r);
}
inline tactic try_for(tactic const & t, unsigned ms) {
Z3_tactic r = Z3_tactic_try_for(t.ctx(), t, ms);
t.check_error();
return tactic(t.ctx(), r);
}
class probe : public object {
Z3_probe m_probe;
@ -1516,6 +1565,22 @@ namespace z3 {
inline func_decl context::function(char const * name, unsigned arity, sort const * domain, sort const & range) {
return function(range.ctx().str_symbol(name), arity, domain, range);
}
inline func_decl context::function(symbol const& name, sort_vector const& domain, sort const& range) {
array<Z3_sort> args(domain.size());
for (unsigned i = 0; i < domain.size(); i++) {
check_context(domain[i], range);
args[i] = domain[i];
}
Z3_func_decl f = Z3_mk_func_decl(m_ctx, name, domain.size(), args.ptr(), range);
check_error();
return func_decl(*this, f);
}
inline func_decl context::function(char const * name, sort_vector const& domain, sort const& range) {
return function(range.ctx().str_symbol(name), domain, range);
}
inline func_decl context::function(char const * name, sort const & domain, sort const & range) {
check_context(domain, range);
@ -1602,6 +1667,16 @@ namespace z3 {
return expr(ctx(), r);
}
inline expr func_decl::operator()(expr_vector const& args) const {
array<Z3_ast> _args(args.size());
for (unsigned i = 0; i < args.size(); i++) {
check_context(*this, args[i]);
_args[i] = args[i];
}
Z3_ast r = Z3_mk_app(ctx(), *this, args.size(), _args.ptr());
check_error();
return expr(ctx(), r);
}
inline expr func_decl::operator()() const {
Z3_ast r = Z3_mk_app(ctx(), *this, 0, 0);
ctx().check_error();

View file

@ -302,8 +302,11 @@ namespace Microsoft.Z3
}
/// <summary>
/// Create a new finite domain sort.
/// Create a new finite domain sort.
/// <returns>The result is a sort</returns>
/// </summary>
/// <param name="name">The name used to identify the sort</param>
/// <param name="size">The size of the sort</param>
public FiniteDomainSort MkFiniteDomainSort(Symbol name, ulong size)
{
Contract.Requires(name != null);
@ -314,8 +317,13 @@ namespace Microsoft.Z3
}
/// <summary>
/// Create a new finite domain sort.
/// Create a new finite domain sort.
/// <returns>The result is a sort</returns>
/// Elements of the sort are created using <seealso cref="MkNumeral(ulong, Sort)"/>,
/// and the elements range from 0 to <tt>size-1</tt>.
/// </summary>
/// <param name="name">The name used to identify the sort</param>
/// <param name="size">The size of the sort</param>
public FiniteDomainSort MkFiniteDomainSort(string name, ulong size)
{
Contract.Ensures(Contract.Result<FiniteDomainSort>() != null);
@ -908,6 +916,8 @@ namespace Microsoft.Z3
CheckContextMatch(t);
return new BoolExpr(this, Native.Z3_mk_or(nCtx, (uint)t.Length, AST.ArrayToNative(t)));
}
#endregion
#region Arithmetic
@ -3513,32 +3523,15 @@ namespace Microsoft.Z3
/// </summary>
/// <remarks>
/// The list of all configuration parameters can be obtained using the Z3 executable:
/// <c>z3.exe -ini?</c>
/// <c>z3.exe -p</c>
/// Only a few configuration parameters are mutable once the context is created.
/// An exception is thrown when trying to modify an immutable parameter.
/// </remarks>
/// <seealso cref="GetParamValue"/>
public void UpdateParamValue(string id, string value)
{
Native.Z3_update_param_value(nCtx, id, value);
}
/// <summary>
/// Get a configuration parameter.
/// </summary>
/// <remarks>
/// Returns null if the parameter value does not exist.
/// </remarks>
/// <seealso cref="UpdateParamValue"/>
public string GetParamValue(string id)
{
IntPtr res = IntPtr.Zero;
if (Native.Z3_get_param_value(nCtx, id, out res) == 0)
return null;
else
return Marshal.PtrToStringAnsi(res);
}
#endregion
#region Internal
@ -3636,7 +3629,7 @@ namespace Microsoft.Z3
internal Fixedpoint.DecRefQueue Fixedpoint_DRQ { get { Contract.Ensures(Contract.Result<Fixedpoint.DecRefQueue>() != null); return m_Fixedpoint_DRQ; } }
internal uint refCount = 0;
internal long refCount = 0;
/// <summary>
/// Finalizer.

View file

@ -99,7 +99,7 @@ namespace Microsoft.Z3
Contract.Requires(Contract.ForAll(args, a => a != null));
Context.CheckContextMatch(args);
if (args.Length != NumArgs)
if (IsApp && args.Length != NumArgs)
throw new Z3Exception("Number of arguments does not match");
NativeObject = Native.Z3_update_term(Context.nCtx, NativeObject, (uint)args.Length, Expr.ArrayToNative(args));
}
@ -269,57 +269,66 @@ namespace Microsoft.Z3
/// <summary>
/// Indicates whether the term is the constant true.
/// </summary>
public bool IsTrue { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_TRUE; } }
public bool IsTrue { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_TRUE; } }
/// <summary>
/// Indicates whether the term is the constant false.
/// </summary>
public bool IsFalse { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FALSE; } }
public bool IsFalse { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FALSE; } }
/// <summary>
/// Indicates whether the term is an equality predicate.
/// </summary>
public bool IsEq { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_EQ; } }
public bool IsEq { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_EQ; } }
/// <summary>
/// Indicates whether the term is an n-ary distinct predicate (every argument is mutually distinct).
/// </summary>
public bool IsDistinct { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_DISTINCT; } }
public bool IsDistinct { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_DISTINCT; } }
/// <summary>
/// Indicates whether the term is a ternary if-then-else term
/// </summary>
public bool IsITE { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ITE; } }
public bool IsITE { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ITE; } }
/// <summary>
/// Indicates whether the term is an n-ary conjunction
/// </summary>
public bool IsAnd { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_AND; } }
public bool IsAnd { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_AND; } }
/// <summary>
/// Indicates whether the term is an n-ary disjunction
/// </summary>
public bool IsOr { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_OR; } }
public bool IsOr { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_OR; } }
/// <summary>
/// Indicates whether the term is an if-and-only-if (Boolean equivalence, binary)
/// </summary>
public bool IsIff { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_IFF; } }
public bool IsIff { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_IFF; } }
/// <summary>
/// Indicates whether the term is an exclusive or
/// </summary>
public bool IsXor { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_XOR; } }
public bool IsXor { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_XOR; } }
/// <summary>
/// Indicates whether the term is a negation
/// </summary>
public bool IsNot { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_NOT; } }
public bool IsNot { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_NOT; } }
/// <summary>
/// Indicates whether the term is an implication
/// </summary>
public bool IsImplies { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_IMPLIES; } }
public bool IsImplies { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_IMPLIES; } }
#endregion
#region Interpolation
/// <summary>
/// Indicates whether the term is marked for interpolation.
/// </summary>
/// <remarks></remarks>
public bool IsInterpolant { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_INTERP; } }
#endregion
#region Arithmetic Terms
@ -346,82 +355,82 @@ namespace Microsoft.Z3
/// <summary>
/// Indicates whether the term is an arithmetic numeral.
/// </summary>
public bool IsArithmeticNumeral { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ANUM; } }
public bool IsArithmeticNumeral { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ANUM; } }
/// <summary>
/// Indicates whether the term is a less-than-or-equal
/// </summary>
public bool IsLE { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_LE; } }
public bool IsLE { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_LE; } }
/// <summary>
/// Indicates whether the term is a greater-than-or-equal
/// </summary>
public bool IsGE { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_GE; } }
public bool IsGE { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_GE; } }
/// <summary>
/// Indicates whether the term is a less-than
/// </summary>
public bool IsLT { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_LT; } }
public bool IsLT { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_LT; } }
/// <summary>
/// Indicates whether the term is a greater-than
/// </summary>
public bool IsGT { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_GT; } }
public bool IsGT { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_GT; } }
/// <summary>
/// Indicates whether the term is addition (binary)
/// </summary>
public bool IsAdd { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ADD; } }
public bool IsAdd { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ADD; } }
/// <summary>
/// Indicates whether the term is subtraction (binary)
/// </summary>
public bool IsSub { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SUB; } }
public bool IsSub { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SUB; } }
/// <summary>
/// Indicates whether the term is a unary minus
/// </summary>
public bool IsUMinus { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_UMINUS; } }
public bool IsUMinus { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_UMINUS; } }
/// <summary>
/// Indicates whether the term is multiplication (binary)
/// </summary>
public bool IsMul { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_MUL; } }
public bool IsMul { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_MUL; } }
/// <summary>
/// Indicates whether the term is division (binary)
/// </summary>
public bool IsDiv { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_DIV; } }
public bool IsDiv { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_DIV; } }
/// <summary>
/// Indicates whether the term is integer division (binary)
/// </summary>
public bool IsIDiv { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_IDIV; } }
public bool IsIDiv { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_IDIV; } }
/// <summary>
/// Indicates whether the term is remainder (binary)
/// </summary>
public bool IsRemainder { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_REM; } }
public bool IsRemainder { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_REM; } }
/// <summary>
/// Indicates whether the term is modulus (binary)
/// </summary>
public bool IsModulus { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_MOD; } }
public bool IsModulus { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_MOD; } }
/// <summary>
/// Indicates whether the term is a coercion of integer to real (unary)
/// </summary>
public bool IsIntToReal { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_TO_REAL; } }
public bool IsIntToReal { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_TO_REAL; } }
/// <summary>
/// Indicates whether the term is a coercion of real to integer (unary)
/// </summary>
public bool IsRealToInt { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_TO_INT; } }
public bool IsRealToInt { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_TO_INT; } }
/// <summary>
/// Indicates whether the term is a check that tests whether a real is integral (unary)
/// </summary>
public bool IsRealIsInt { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_IS_INT; } }
public bool IsRealIsInt { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_IS_INT; } }
#endregion
#region Array Terms
@ -443,64 +452,64 @@ namespace Microsoft.Z3
/// </summary>
/// <remarks>It satisfies select(store(a,i,v),j) = if i = j then v else select(a,j).
/// Array store takes at least 3 arguments. </remarks>
public bool IsStore { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_STORE; } }
public bool IsStore { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_STORE; } }
/// <summary>
/// Indicates whether the term is an array select.
/// </summary>
public bool IsSelect { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SELECT; } }
public bool IsSelect { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SELECT; } }
/// <summary>
/// Indicates whether the term is a constant array.
/// </summary>
/// <remarks>For example, select(const(v),i) = v holds for every v and i. The function is unary.</remarks>
public bool IsConstantArray { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_CONST_ARRAY; } }
public bool IsConstantArray { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_CONST_ARRAY; } }
/// <summary>
/// Indicates whether the term is a default array.
/// </summary>
/// <remarks>For example default(const(v)) = v. The function is unary.</remarks>
public bool IsDefaultArray { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ARRAY_DEFAULT; } }
public bool IsDefaultArray { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ARRAY_DEFAULT; } }
/// <summary>
/// Indicates whether the term is an array map.
/// </summary>
/// <remarks>It satisfies map[f](a1,..,a_n)[i] = f(a1[i],...,a_n[i]) for every i.</remarks>
public bool IsArrayMap { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ARRAY_MAP; } }
public bool IsArrayMap { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ARRAY_MAP; } }
/// <summary>
/// Indicates whether the term is an as-array term.
/// </summary>
/// <remarks>An as-array term is n array value that behaves as the function graph of the
/// function passed as parameter.</remarks>
public bool IsAsArray { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_AS_ARRAY; } }
public bool IsAsArray { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_AS_ARRAY; } }
#endregion
#region Set Terms
/// <summary>
/// Indicates whether the term is set union
/// </summary>
public bool IsSetUnion { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SET_UNION; } }
public bool IsSetUnion { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SET_UNION; } }
/// <summary>
/// Indicates whether the term is set intersection
/// </summary>
public bool IsSetIntersect { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SET_INTERSECT; } }
public bool IsSetIntersect { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SET_INTERSECT; } }
/// <summary>
/// Indicates whether the term is set difference
/// </summary>
public bool IsSetDifference { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SET_DIFFERENCE; } }
public bool IsSetDifference { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SET_DIFFERENCE; } }
/// <summary>
/// Indicates whether the term is set complement
/// </summary>
public bool IsSetComplement { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SET_COMPLEMENT; } }
public bool IsSetComplement { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SET_COMPLEMENT; } }
/// <summary>
/// Indicates whether the term is set subset
/// </summary>
public bool IsSetSubset { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SET_SUBSET; } }
public bool IsSetSubset { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SET_SUBSET; } }
#endregion
#region Bit-vector terms
@ -515,266 +524,266 @@ namespace Microsoft.Z3
/// <summary>
/// Indicates whether the term is a bit-vector numeral
/// </summary>
public bool IsBVNumeral { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BNUM; } }
public bool IsBVNumeral { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BNUM; } }
/// <summary>
/// Indicates whether the term is a one-bit bit-vector with value one
/// </summary>
public bool IsBVBitOne { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BIT1; } }
public bool IsBVBitOne { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BIT1; } }
/// <summary>
/// Indicates whether the term is a one-bit bit-vector with value zero
/// </summary>
public bool IsBVBitZero { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BIT0; } }
public bool IsBVBitZero { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BIT0; } }
/// <summary>
/// Indicates whether the term is a bit-vector unary minus
/// </summary>
public bool IsBVUMinus { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BNEG; } }
public bool IsBVUMinus { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BNEG; } }
/// <summary>
/// Indicates whether the term is a bit-vector addition (binary)
/// </summary>
public bool IsBVAdd { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BADD; } }
public bool IsBVAdd { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BADD; } }
/// <summary>
/// Indicates whether the term is a bit-vector subtraction (binary)
/// </summary>
public bool IsBVSub { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BSUB; } }
public bool IsBVSub { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BSUB; } }
/// <summary>
/// Indicates whether the term is a bit-vector multiplication (binary)
/// </summary>
public bool IsBVMul { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BMUL; } }
public bool IsBVMul { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BMUL; } }
/// <summary>
/// Indicates whether the term is a bit-vector signed division (binary)
/// </summary>
public bool IsBVSDiv { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BSDIV; } }
public bool IsBVSDiv { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BSDIV; } }
/// <summary>
/// Indicates whether the term is a bit-vector unsigned division (binary)
/// </summary>
public bool IsBVUDiv { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BUDIV; } }
public bool IsBVUDiv { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BUDIV; } }
/// <summary>
/// Indicates whether the term is a bit-vector signed remainder (binary)
/// </summary>
public bool IsBVSRem { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BSREM; } }
public bool IsBVSRem { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BSREM; } }
/// <summary>
/// Indicates whether the term is a bit-vector unsigned remainder (binary)
/// </summary>
public bool IsBVURem { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BUREM; } }
public bool IsBVURem { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BUREM; } }
/// <summary>
/// Indicates whether the term is a bit-vector signed modulus
/// </summary>
public bool IsBVSMod { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BSMOD; } }
public bool IsBVSMod { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BSMOD; } }
/// <summary>
/// Indicates whether the term is a bit-vector signed division by zero
/// </summary>
internal bool IsBVSDiv0 { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BSDIV0; } }
internal bool IsBVSDiv0 { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BSDIV0; } }
/// <summary>
/// Indicates whether the term is a bit-vector unsigned division by zero
/// </summary>
internal bool IsBVUDiv0 { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BUDIV0; } }
internal bool IsBVUDiv0 { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BUDIV0; } }
/// <summary>
/// Indicates whether the term is a bit-vector signed remainder by zero
/// </summary>
internal bool IsBVSRem0 { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BSREM0; } }
internal bool IsBVSRem0 { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BSREM0; } }
/// <summary>
/// Indicates whether the term is a bit-vector unsigned remainder by zero
/// </summary>
internal bool IsBVURem0 { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BUREM0; } }
internal bool IsBVURem0 { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BUREM0; } }
/// <summary>
/// Indicates whether the term is a bit-vector signed modulus by zero
/// </summary>
internal bool IsBVSMod0 { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BSMOD0; } }
internal bool IsBVSMod0 { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BSMOD0; } }
/// <summary>
/// Indicates whether the term is an unsigned bit-vector less-than-or-equal
/// </summary>
public bool IsBVULE { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ULEQ; } }
public bool IsBVULE { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ULEQ; } }
/// <summary>
/// Indicates whether the term is a signed bit-vector less-than-or-equal
/// </summary>
public bool IsBVSLE { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SLEQ; } }
public bool IsBVSLE { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SLEQ; } }
/// <summary>
/// Indicates whether the term is an unsigned bit-vector greater-than-or-equal
/// </summary>
public bool IsBVUGE { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_UGEQ; } }
public bool IsBVUGE { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_UGEQ; } }
/// <summary>
/// Indicates whether the term is a signed bit-vector greater-than-or-equal
/// </summary>
public bool IsBVSGE { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SGEQ; } }
public bool IsBVSGE { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SGEQ; } }
/// <summary>
/// Indicates whether the term is an unsigned bit-vector less-than
/// </summary>
public bool IsBVULT { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ULT; } }
public bool IsBVULT { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ULT; } }
/// <summary>
/// Indicates whether the term is a signed bit-vector less-than
/// </summary>
public bool IsBVSLT { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SLT; } }
public bool IsBVSLT { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SLT; } }
/// <summary>
/// Indicates whether the term is an unsigned bit-vector greater-than
/// </summary>
public bool IsBVUGT { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_UGT; } }
public bool IsBVUGT { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_UGT; } }
/// <summary>
/// Indicates whether the term is a signed bit-vector greater-than
/// </summary>
public bool IsBVSGT { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SGT; } }
public bool IsBVSGT { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SGT; } }
/// <summary>
/// Indicates whether the term is a bit-wise AND
/// </summary>
public bool IsBVAND { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BAND; } }
public bool IsBVAND { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BAND; } }
/// <summary>
/// Indicates whether the term is a bit-wise OR
/// </summary>
public bool IsBVOR { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BOR; } }
public bool IsBVOR { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BOR; } }
/// <summary>
/// Indicates whether the term is a bit-wise NOT
/// </summary>
public bool IsBVNOT { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BNOT; } }
public bool IsBVNOT { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BNOT; } }
/// <summary>
/// Indicates whether the term is a bit-wise XOR
/// </summary>
public bool IsBVXOR { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BXOR; } }
public bool IsBVXOR { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BXOR; } }
/// <summary>
/// Indicates whether the term is a bit-wise NAND
/// </summary>
public bool IsBVNAND { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BNAND; } }
public bool IsBVNAND { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BNAND; } }
/// <summary>
/// Indicates whether the term is a bit-wise NOR
/// </summary>
public bool IsBVNOR { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BNOR; } }
public bool IsBVNOR { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BNOR; } }
/// <summary>
/// Indicates whether the term is a bit-wise XNOR
/// </summary>
public bool IsBVXNOR { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BXNOR; } }
public bool IsBVXNOR { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BXNOR; } }
/// <summary>
/// Indicates whether the term is a bit-vector concatenation (binary)
/// </summary>
public bool IsBVConcat { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_CONCAT; } }
public bool IsBVConcat { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_CONCAT; } }
/// <summary>
/// Indicates whether the term is a bit-vector sign extension
/// </summary>
public bool IsBVSignExtension { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SIGN_EXT; } }
public bool IsBVSignExtension { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SIGN_EXT; } }
/// <summary>
/// Indicates whether the term is a bit-vector zero extension
/// </summary>
public bool IsBVZeroExtension { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ZERO_EXT; } }
public bool IsBVZeroExtension { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ZERO_EXT; } }
/// <summary>
/// Indicates whether the term is a bit-vector extraction
/// </summary>
public bool IsBVExtract { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_EXTRACT; } }
public bool IsBVExtract { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_EXTRACT; } }
/// <summary>
/// Indicates whether the term is a bit-vector repetition
/// </summary>
public bool IsBVRepeat { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_REPEAT; } }
public bool IsBVRepeat { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_REPEAT; } }
/// <summary>
/// Indicates whether the term is a bit-vector reduce OR
/// </summary>
public bool IsBVReduceOR { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BREDOR; } }
public bool IsBVReduceOR { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BREDOR; } }
/// <summary>
/// Indicates whether the term is a bit-vector reduce AND
/// </summary>
public bool IsBVReduceAND { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BREDAND; } }
public bool IsBVReduceAND { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BREDAND; } }
/// <summary>
/// Indicates whether the term is a bit-vector comparison
/// </summary>
public bool IsBVComp { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BCOMP; } }
public bool IsBVComp { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BCOMP; } }
/// <summary>
/// Indicates whether the term is a bit-vector shift left
/// </summary>
public bool IsBVShiftLeft { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BSHL; } }
public bool IsBVShiftLeft { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BSHL; } }
/// <summary>
/// Indicates whether the term is a bit-vector logical shift right
/// </summary>
public bool IsBVShiftRightLogical { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BLSHR; } }
public bool IsBVShiftRightLogical { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BLSHR; } }
/// <summary>
/// Indicates whether the term is a bit-vector arithmetic shift left
/// </summary>
public bool IsBVShiftRightArithmetic { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BASHR; } }
public bool IsBVShiftRightArithmetic { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BASHR; } }
/// <summary>
/// Indicates whether the term is a bit-vector rotate left
/// </summary>
public bool IsBVRotateLeft { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ROTATE_LEFT; } }
public bool IsBVRotateLeft { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ROTATE_LEFT; } }
/// <summary>
/// Indicates whether the term is a bit-vector rotate right
/// </summary>
public bool IsBVRotateRight { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ROTATE_RIGHT; } }
public bool IsBVRotateRight { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_ROTATE_RIGHT; } }
/// <summary>
/// Indicates whether the term is a bit-vector rotate left (extended)
/// </summary>
/// <remarks>Similar to Z3_OP_ROTATE_LEFT, but it is a binary operator instead of a parametric one.</remarks>
public bool IsBVRotateLeftExtended { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_EXT_ROTATE_LEFT; } }
public bool IsBVRotateLeftExtended { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_EXT_ROTATE_LEFT; } }
/// <summary>
/// Indicates whether the term is a bit-vector rotate right (extended)
/// </summary>
/// <remarks>Similar to Z3_OP_ROTATE_RIGHT, but it is a binary operator instead of a parametric one.</remarks>
public bool IsBVRotateRightExtended { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_EXT_ROTATE_RIGHT; } }
public bool IsBVRotateRightExtended { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_EXT_ROTATE_RIGHT; } }
/// <summary>
/// Indicates whether the term is a coercion from integer to bit-vector
/// </summary>
/// <remarks>This function is not supported by the decision procedures. Only the most
/// rudimentary simplification rules are applied to this function.</remarks>
public bool IsIntToBV { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_INT2BV; } }
public bool IsIntToBV { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_INT2BV; } }
/// <summary>
/// Indicates whether the term is a coercion from bit-vector to integer
/// </summary>
/// <remarks>This function is not supported by the decision procedures. Only the most
/// rudimentary simplification rules are applied to this function.</remarks>
public bool IsBVToInt { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BV2INT; } }
public bool IsBVToInt { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_BV2INT; } }
/// <summary>
/// Indicates whether the term is a bit-vector carry
/// </summary>
/// <remarks>Compute the carry bit in a full-adder. The meaning is given by the
/// equivalence (carry l1 l2 l3) &lt;=&gt; (or (and l1 l2) (and l1 l3) (and l2 l3)))</remarks>
public bool IsBVCarry { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_CARRY; } }
public bool IsBVCarry { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_CARRY; } }
/// <summary>
/// Indicates whether the term is a bit-vector ternary XOR
/// </summary>
/// <remarks>The meaning is given by the equivalence (xor3 l1 l2 l3) &lt;=&gt; (xor (xor l1 l2) l3)</remarks>
public bool IsBVXOR3 { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_XOR3; } }
public bool IsBVXOR3 { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_XOR3; } }
#endregion
@ -783,14 +792,14 @@ namespace Microsoft.Z3
/// Indicates whether the term is a label (used by the Boogie Verification condition generator).
/// </summary>
/// <remarks>The label has two parameters, a string and a Boolean polarity. It takes one argument, a formula.</remarks>
public bool IsLabel { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_LABEL; } }
public bool IsLabel { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_LABEL; } }
/// <summary>
/// Indicates whether the term is a label literal (used by the Boogie Verification condition generator).
/// </summary>
/// <remarks>A label literal has a set of string parameters. It takes no arguments.</remarks>
public bool IsLabelLit { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_LABEL_LIT; } }
#endregion
public bool IsLabelLit { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_LABEL_LIT; } }
#endregion
#region Proof Terms
/// <summary>
@ -798,22 +807,22 @@ namespace Microsoft.Z3
/// </summary>
/// <remarks>This binary predicate is used in proof terms.
/// It captures equisatisfiability and equivalence modulo renamings.</remarks>
public bool IsOEQ { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_OEQ; } }
public bool IsOEQ { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_OEQ; } }
/// <summary>
/// Indicates whether the term is a Proof for the expression 'true'.
/// </summary>
public bool IsProofTrue { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_TRUE; } }
public bool IsProofTrue { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_TRUE; } }
/// <summary>
/// Indicates whether the term is a proof for a fact asserted by the user.
/// </summary>
public bool IsProofAsserted { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_ASSERTED; } }
public bool IsProofAsserted { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_ASSERTED; } }
/// <summary>
/// Indicates whether the term is a proof for a fact (tagged as goal) asserted by the user.
/// </summary>
public bool IsProofGoal { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_GOAL; } }
public bool IsProofGoal { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_GOAL; } }
/// <summary>
/// Indicates whether the term is proof via modus ponens
@ -824,7 +833,7 @@ namespace Microsoft.Z3
/// T2: (implies p q)
/// [mp T1 T2]: q
/// The second antecedents may also be a proof for (iff p q).</remarks>
public bool IsProofModusPonens { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_MODUS_PONENS; } }
public bool IsProofModusPonens { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_MODUS_PONENS; } }
/// <summary>
/// Indicates whether the term is a proof for (R t t), where R is a reflexive relation.
@ -833,7 +842,7 @@ namespace Microsoft.Z3
/// The only reflexive relations that are used are
/// equivalence modulo namings, equality and equivalence.
/// That is, R is either '~', '=' or 'iff'.</remarks>
public bool IsProofReflexivity { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_REFLEXIVITY; } }
public bool IsProofReflexivity { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_REFLEXIVITY; } }
/// <summary>
/// Indicates whether the term is proof by symmetricity of a relation
@ -844,7 +853,7 @@ namespace Microsoft.Z3
/// [symmetry T1]: (R s t)
/// T1 is the antecedent of this proof object.
/// </remarks>
public bool IsProofSymmetry { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_SYMMETRY; } }
public bool IsProofSymmetry { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_SYMMETRY; } }
/// <summary>
/// Indicates whether the term is a proof by transitivity of a relation
@ -856,7 +865,7 @@ namespace Microsoft.Z3
/// T2: (R s u)
/// [trans T1 T2]: (R t u)
/// </remarks>
public bool IsProofTransitivity { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_TRANSITIVITY; } }
public bool IsProofTransitivity { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_TRANSITIVITY; } }
/// <summary>
/// Indicates whether the term is a proof by condensed transitivity of a relation
@ -877,7 +886,7 @@ namespace Microsoft.Z3
/// if there is a path from s to t, if we view every
/// antecedent (R a b) as an edge between a and b.
/// </remarks>
public bool IsProofTransitivityStar { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_TRANSITIVITY_STAR; } }
public bool IsProofTransitivityStar { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_TRANSITIVITY_STAR; } }
/// <summary>
@ -891,7 +900,7 @@ namespace Microsoft.Z3
/// Remark: if t_i == s_i, then the antecedent Ti is suppressed.
/// That is, reflexivity proofs are supressed to save space.
/// </remarks>
public bool IsProofMonotonicity { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_MONOTONICITY; } }
public bool IsProofMonotonicity { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_MONOTONICITY; } }
/// <summary>
/// Indicates whether the term is a quant-intro proof
@ -901,7 +910,7 @@ namespace Microsoft.Z3
/// T1: (~ p q)
/// [quant-intro T1]: (~ (forall (x) p) (forall (x) q))
/// </remarks>
public bool IsProofQuantIntro { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_QUANT_INTRO; } }
public bool IsProofQuantIntro { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_QUANT_INTRO; } }
/// <summary>
/// Indicates whether the term is a distributivity proof object.
@ -919,7 +928,7 @@ namespace Microsoft.Z3
/// Remark. This rule is used by the CNF conversion pass and
/// instantiated by f = or, and g = and.
/// </remarks>
public bool IsProofDistributivity { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_DISTRIBUTIVITY; } }
public bool IsProofDistributivity { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_DISTRIBUTIVITY; } }
/// <summary>
/// Indicates whether the term is a proof by elimination of AND
@ -929,7 +938,7 @@ namespace Microsoft.Z3
/// T1: (and l_1 ... l_n)
/// [and-elim T1]: l_i
/// </remarks>
public bool IsProofAndElimination { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_AND_ELIM; } }
public bool IsProofAndElimination { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_AND_ELIM; } }
/// <summary>
/// Indicates whether the term is a proof by eliminiation of not-or
@ -939,7 +948,7 @@ namespace Microsoft.Z3
/// T1: (not (or l_1 ... l_n))
/// [not-or-elim T1]: (not l_i)
/// </remarks>
public bool IsProofOrElimination { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_NOT_OR_ELIM; } }
public bool IsProofOrElimination { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_NOT_OR_ELIM; } }
/// <summary>
/// Indicates whether the term is a proof by rewriting
@ -958,7 +967,7 @@ namespace Microsoft.Z3
/// (= (+ x 1 2) (+ 3 x))
/// (iff (or x false) x)
/// </remarks>
public bool IsProofRewrite { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_REWRITE; } }
public bool IsProofRewrite { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_REWRITE; } }
/// <summary>
/// Indicates whether the term is a proof by rewriting
@ -974,7 +983,7 @@ namespace Microsoft.Z3
/// - When converting bit-vectors to Booleans (BIT2BOOL=true)
/// - When pulling ite expression up (PULL_CHEAP_ITE_TREES=true)
/// </remarks>
public bool IsProofRewriteStar { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_REWRITE_STAR; } }
public bool IsProofRewriteStar { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_REWRITE_STAR; } }
/// <summary>
/// Indicates whether the term is a proof for pulling quantifiers out.
@ -982,7 +991,7 @@ namespace Microsoft.Z3
/// <remarks>
/// A proof for (iff (f (forall (x) q(x)) r) (forall (x) (f (q x) r))). This proof object has no antecedents.
/// </remarks>
public bool IsProofPullQuant { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_PULL_QUANT; } }
public bool IsProofPullQuant { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_PULL_QUANT; } }
/// <summary>
/// Indicates whether the term is a proof for pulling quantifiers out.
@ -992,7 +1001,7 @@ namespace Microsoft.Z3
/// This proof object is only used if the parameter PROOF_MODE is 1.
/// This proof object has no antecedents
/// </remarks>
public bool IsProofPullQuantStar { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_PULL_QUANT_STAR; } }
public bool IsProofPullQuantStar { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_PULL_QUANT_STAR; } }
/// <summary>
/// Indicates whether the term is a proof for pushing quantifiers in.
@ -1005,7 +1014,7 @@ namespace Microsoft.Z3
/// (forall (x_1 ... x_m) p_n[x_1 ... x_m])))
/// This proof object has no antecedents
/// </remarks>
public bool IsProofPushQuant { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_PUSH_QUANT; } }
public bool IsProofPushQuant { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_PUSH_QUANT; } }
/// <summary>
/// Indicates whether the term is a proof for elimination of unused variables.
@ -1017,7 +1026,7 @@ namespace Microsoft.Z3
/// It is used to justify the elimination of unused variables.
/// This proof object has no antecedents.
/// </remarks>
public bool IsProofElimUnusedVars { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_ELIM_UNUSED_VARS; } }
public bool IsProofElimUnusedVars { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_ELIM_UNUSED_VARS; } }
/// <summary>
/// Indicates whether the term is a proof for destructive equality resolution
@ -1031,7 +1040,7 @@ namespace Microsoft.Z3
///
/// Several variables can be eliminated simultaneously.
/// </remarks>
public bool IsProofDER { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_DER; } }
public bool IsProofDER { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_DER; } }
/// <summary>
/// Indicates whether the term is a proof for quantifier instantiation
@ -1039,13 +1048,13 @@ namespace Microsoft.Z3
/// <remarks>
/// A proof of (or (not (forall (x) (P x))) (P a))
/// </remarks>
public bool IsProofQuantInst { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_QUANT_INST; } }
public bool IsProofQuantInst { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_QUANT_INST; } }
/// <summary>
/// Indicates whether the term is a hypthesis marker.
/// </summary>
/// <remarks>Mark a hypothesis in a natural deduction style proof.</remarks>
public bool IsProofHypothesis { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_HYPOTHESIS; } }
public bool IsProofHypothesis { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_HYPOTHESIS; } }
/// <summary>
/// Indicates whether the term is a proof by lemma
@ -1058,7 +1067,7 @@ namespace Microsoft.Z3
/// It converts the proof in a proof for (or (not l_1) ... (not l_n)),
/// when T1 contains the hypotheses: l_1, ..., l_n.
/// </remarks>
public bool IsProofLemma { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_LEMMA; } }
public bool IsProofLemma { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_LEMMA; } }
/// <summary>
/// Indicates whether the term is a proof by unit resolution
@ -1070,7 +1079,7 @@ namespace Microsoft.Z3
/// T(n+1): (not l_n)
/// [unit-resolution T1 ... T(n+1)]: (or l_1' ... l_m')
/// </remarks>
public bool IsProofUnitResolution { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_UNIT_RESOLUTION; } }
public bool IsProofUnitResolution { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_UNIT_RESOLUTION; } }
/// <summary>
/// Indicates whether the term is a proof by iff-true
@ -1079,7 +1088,7 @@ namespace Microsoft.Z3
/// T1: p
/// [iff-true T1]: (iff p true)
/// </remarks>
public bool IsProofIFFTrue { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_IFF_TRUE; } }
public bool IsProofIFFTrue { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_IFF_TRUE; } }
/// <summary>
/// Indicates whether the term is a proof by iff-false
@ -1088,7 +1097,7 @@ namespace Microsoft.Z3
/// T1: (not p)
/// [iff-false T1]: (iff p false)
/// </remarks>
public bool IsProofIFFFalse { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_IFF_FALSE; } }
public bool IsProofIFFFalse { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_IFF_FALSE; } }
/// <summary>
/// Indicates whether the term is a proof by commutativity
@ -1101,7 +1110,7 @@ namespace Microsoft.Z3
/// This proof object has no antecedents.
/// Remark: if f is bool, then = is iff.
/// </remarks>
public bool IsProofCommutativity { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_COMMUTATIVITY; } }
public bool IsProofCommutativity { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_COMMUTATIVITY; } }
/// <summary>
/// Indicates whether the term is a proof for Tseitin-like axioms
@ -1137,7 +1146,7 @@ namespace Microsoft.Z3
/// unfolding the Boolean connectives in the axioms a small
/// bounded number of steps (=3).
/// </remarks>
public bool IsProofDefAxiom { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_DEF_AXIOM; } }
public bool IsProofDefAxiom { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_DEF_AXIOM; } }
/// <summary>
/// Indicates whether the term is a proof for introduction of a name
@ -1160,7 +1169,7 @@ namespace Microsoft.Z3
/// Otherwise:
/// [def-intro]: (= n e)
/// </remarks>
public bool IsProofDefIntro { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_DEF_INTRO; } }
public bool IsProofDefIntro { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_DEF_INTRO; } }
/// <summary>
/// Indicates whether the term is a proof for application of a definition
@ -1170,7 +1179,7 @@ namespace Microsoft.Z3
/// F is 'equivalent' to n, given that T1 is a proof that
/// n is a name for F.
/// </remarks>
public bool IsProofApplyDef { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_APPLY_DEF; } }
public bool IsProofApplyDef { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_APPLY_DEF; } }
/// <summary>
/// Indicates whether the term is a proof iff-oeq
@ -1179,7 +1188,7 @@ namespace Microsoft.Z3
/// T1: (iff p q)
/// [iff~ T1]: (~ p q)
/// </remarks>
public bool IsProofIFFOEQ { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_IFF_OEQ; } }
public bool IsProofIFFOEQ { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_IFF_OEQ; } }
/// <summary>
/// Indicates whether the term is a proof for a positive NNF step
@ -1207,7 +1216,7 @@ namespace Microsoft.Z3
/// NNF_NEG furthermore handles the case where negation is pushed
/// over Boolean connectives 'and' and 'or'.
/// </remarks>
public bool IsProofNNFPos { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_NNF_POS; } }
public bool IsProofNNFPos { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_NNF_POS; } }
/// <summary>
/// Indicates whether the term is a proof for a negative NNF step
@ -1232,7 +1241,7 @@ namespace Microsoft.Z3
/// [nnf-neg T1 T2 T3 T4]: (~ (not (iff s_1 s_2))
/// (and (or r_1 r_2) (or r_1' r_2')))
/// </remarks>
public bool IsProofNNFNeg { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_NNF_NEG; } }
public bool IsProofNNFNeg { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_NNF_NEG; } }
/// <summary>
/// Indicates whether the term is a proof for (~ P Q) here Q is in negation normal form.
@ -1244,7 +1253,7 @@ namespace Microsoft.Z3
///
/// This proof object may have n antecedents. Each antecedent is a PR_DEF_INTRO.
/// </remarks>
public bool IsProofNNFStar { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_NNF_STAR; } }
public bool IsProofNNFStar { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_NNF_STAR; } }
/// <summary>
/// Indicates whether the term is a proof for (~ P Q) where Q is in conjunctive normal form.
@ -1254,7 +1263,7 @@ namespace Microsoft.Z3
/// This proof object is only used if the parameter PROOF_MODE is 1.
/// This proof object may have n antecedents. Each antecedent is a PR_DEF_INTRO.
/// </remarks>
public bool IsProofCNFStar { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_CNF_STAR; } }
public bool IsProofCNFStar { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_CNF_STAR; } }
/// <summary>
/// Indicates whether the term is a proof for a Skolemization step
@ -1267,7 +1276,7 @@ namespace Microsoft.Z3
///
/// This proof object has no antecedents.
/// </remarks>
public bool IsProofSkolemize { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_SKOLEMIZE; } }
public bool IsProofSkolemize { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_SKOLEMIZE; } }
/// <summary>
/// Indicates whether the term is a proof by modus ponens for equi-satisfiability.
@ -1278,7 +1287,7 @@ namespace Microsoft.Z3
/// T2: (~ p q)
/// [mp~ T1 T2]: q
/// </remarks>
public bool IsProofModusPonensOEQ { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_MODUS_PONENS_OEQ; } }
public bool IsProofModusPonensOEQ { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_MODUS_PONENS_OEQ; } }
/// <summary>
/// Indicates whether the term is a proof for theory lemma
@ -1297,7 +1306,7 @@ namespace Microsoft.Z3
/// (iff (= t1 t2) (and (&lt;= t1 t2) (&lt;= t2 t1)))
/// - gcd-test - Indicates an integer linear arithmetic lemma that uses a gcd test.
/// </remarks>
public bool IsProofTheoryLemma { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_TH_LEMMA; } }
public bool IsProofTheoryLemma { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_PR_TH_LEMMA; } }
#endregion
#region Relational Terms
@ -1322,40 +1331,40 @@ namespace Microsoft.Z3
/// The function takes <c>n+1</c> arguments, where the first argument is the relation and the remaining <c>n</c> elements
/// correspond to the <c>n</c> columns of the relation.
/// </remarks>
public bool IsRelationStore { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_STORE; } }
public bool IsRelationStore { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_STORE; } }
/// <summary>
/// Indicates whether the term is an empty relation
/// </summary>
public bool IsEmptyRelation { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_EMPTY; } }
public bool IsEmptyRelation { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_EMPTY; } }
/// <summary>
/// Indicates whether the term is a test for the emptiness of a relation
/// </summary>
public bool IsIsEmptyRelation { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_IS_EMPTY; } }
public bool IsIsEmptyRelation { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_IS_EMPTY; } }
/// <summary>
/// Indicates whether the term is a relational join
/// </summary>
public bool IsRelationalJoin { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_JOIN; } }
public bool IsRelationalJoin { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_JOIN; } }
/// <summary>
/// Indicates whether the term is the union or convex hull of two relations.
/// </summary>
/// <remarks>The function takes two arguments.</remarks>
public bool IsRelationUnion { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_UNION; } }
public bool IsRelationUnion { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_UNION; } }
/// <summary>
/// Indicates whether the term is the widening of two relations
/// </summary>
/// <remarks>The function takes two arguments.</remarks>
public bool IsRelationWiden { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_WIDEN; } }
public bool IsRelationWiden { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_WIDEN; } }
/// <summary>
/// Indicates whether the term is a projection of columns (provided as numbers in the parameters).
/// </summary>
/// <remarks>The function takes one argument.</remarks>
public bool IsRelationProject { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_PROJECT; } }
public bool IsRelationProject { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_PROJECT; } }
/// <summary>
/// Indicates whether the term is a relation filter
@ -1367,7 +1376,7 @@ namespace Microsoft.Z3
/// corresponding to the columns of the relation.
/// So the first column in the relation has index 0.
/// </remarks>
public bool IsRelationFilter { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_FILTER; } }
public bool IsRelationFilter { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_FILTER; } }
/// <summary>
/// Indicates whether the term is an intersection of a relation with the negation of another.
@ -1383,7 +1392,7 @@ namespace Microsoft.Z3
/// target are elements in x in pos, such that there is no y in neg that agrees with
/// x on the columns c1, d1, .., cN, dN.
/// </remarks>
public bool IsRelationNegationFilter { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_NEGATION_FILTER; } }
public bool IsRelationNegationFilter { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_NEGATION_FILTER; } }
/// <summary>
/// Indicates whether the term is the renaming of a column in a relation
@ -1392,12 +1401,12 @@ namespace Microsoft.Z3
/// The function takes one argument.
/// The parameters contain the renaming as a cycle.
/// </remarks>
public bool IsRelationRename { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_RENAME; } }
public bool IsRelationRename { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_RENAME; } }
/// <summary>
/// Indicates whether the term is the complement of a relation
/// </summary>
public bool IsRelationComplement { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_COMPLEMENT; } }
public bool IsRelationComplement { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_COMPLEMENT; } }
/// <summary>
/// Indicates whether the term is a relational select
@ -1407,7 +1416,7 @@ namespace Microsoft.Z3
/// The function takes <c>n+1</c> arguments, where the first argument is a relation,
/// and the remaining <c>n</c> arguments correspond to a record.
/// </remarks>
public bool IsRelationSelect { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_SELECT; } }
public bool IsRelationSelect { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_SELECT; } }
/// <summary>
/// Indicates whether the term is a relational clone (copy)
@ -1419,7 +1428,7 @@ namespace Microsoft.Z3
/// for terms of kind <seealso cref="IsRelationUnion"/>
/// to perform destructive updates to the first argument.
/// </remarks>
public bool IsRelationClone { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_CLONE; } }
public bool IsRelationClone { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_RA_CLONE; } }
#endregion
#region Finite domain terms
@ -1438,7 +1447,7 @@ namespace Microsoft.Z3
/// <summary>
/// Indicates whether the term is a less than predicate over a finite domain.
/// </summary>
public bool IsFiniteDomainLT { get { return FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FD_LT; } }
public bool IsFiniteDomainLT { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FD_LT; } }
#endregion
#endregion

View file

@ -269,6 +269,14 @@ namespace Microsoft.Z3
AST.ArrayLength(queries), AST.ArrayToNative(queries));
}
BoolExpr[] ToBoolExprs(ASTVector v) {
uint n = v.Size;
BoolExpr[] res = new BoolExpr[n];
for (uint i = 0; i < n; i++)
res[i] = new BoolExpr(Context, v[i].NativeObject);
return res;
}
/// <summary>
/// Retrieve set of rules added to fixedpoint context.
/// </summary>
@ -278,12 +286,7 @@ namespace Microsoft.Z3
{
Contract.Ensures(Contract.Result<BoolExpr[]>() != null);
ASTVector v = new ASTVector(Context, Native.Z3_fixedpoint_get_rules(Context.nCtx, NativeObject));
uint n = v.Size;
BoolExpr[] res = new BoolExpr[n];
for (uint i = 0; i < n; i++)
res[i] = new BoolExpr(Context, v[i].NativeObject);
return res;
return ToBoolExprs(new ASTVector(Context, Native.Z3_fixedpoint_get_rules(Context.nCtx, NativeObject)));
}
}
@ -296,15 +299,27 @@ namespace Microsoft.Z3
{
Contract.Ensures(Contract.Result<BoolExpr[]>() != null);
ASTVector v = new ASTVector(Context, Native.Z3_fixedpoint_get_assertions(Context.nCtx, NativeObject));
uint n = v.Size;
BoolExpr[] res = new BoolExpr[n];
for (uint i = 0; i < n; i++)
res[i] = new BoolExpr(Context, v[i].NativeObject);
return res;
return ToBoolExprs(new ASTVector(Context, Native.Z3_fixedpoint_get_assertions(Context.nCtx, NativeObject)));
}
}
/// <summary>
/// Parse an SMT-LIB2 file with fixedpoint rules.
/// Add the rules to the current fixedpoint context.
/// Return the set of queries in the file.
/// </summary>
public BoolExpr[] ParseFile(string file) {
return ToBoolExprs(new ASTVector(Context, Native.Z3_fixedpoint_from_file(Context.nCtx, NativeObject, file)));
}
/// <summary>
/// Similar to ParseFile. Instead it takes as argument a string.
/// </summary>
public BoolExpr[] ParseString(string s) {
return ToBoolExprs(new ASTVector(Context, Native.Z3_fixedpoint_from_string(Context.nCtx, NativeObject, s)));
}
#region Internal
internal Fixedpoint(Context ctx, IntPtr obj)

View file

@ -43,7 +43,7 @@ namespace Microsoft.Z3
/// The parameter names are case-insensitive. The character '-' should be viewed as an "alias" for '_'.
/// Thus, the following parameter names are considered equivalent: "pp.decimal-precision" and "PP.DECIMAL_PRECISION".
/// This function can be used to set parameters for a specific Z3 module.
/// This can be done by using <module-name>.<parameter-name>.
/// This can be done by using [module-name].[parameter-name].
/// For example:
/// Z3_global_param_set('pp.decimal', 'true')
/// will set the parameter "decimal" in the module "pp" to true.

View file

@ -0,0 +1,162 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
namespace Microsoft.Z3
{
/// <summary>
/// The InterpolationContext is suitable for generation of interpolants.
/// </summary>
/// <remarks>For more information on interpolation please refer
/// too the C/C++ API, which is well documented.</remarks>
[ContractVerification(true)]
class InterpolationContext : Context
{
/// <summary>
/// Constructor.
/// </summary>
public InterpolationContext() : base() { }
/// <summary>
/// Constructor.
/// </summary>
/// <remarks><seealso cref="Context.Context(Dictionary&lt;string, string&gt;)"/></remarks>
public InterpolationContext(Dictionary<string, string> settings) : base(settings) { }
#region Terms
/// <summary>
/// Create an expression that marks a formula position for interpolation.
/// </summary>
public BoolExpr MkInterpolant(BoolExpr a)
{
Contract.Requires(a != null);
Contract.Ensures(Contract.Result<BoolExpr>() != null);
CheckContextMatch(a);
return new BoolExpr(this, Native.Z3_mk_interpolant(nCtx, a.NativeObject));
}
#endregion
/// <summary>
/// Computes an interpolant.
/// </summary>
/// <remarks>For more information on interpolation please refer
/// too the function Z3_get_interpolant in the C/C++ API, which is
/// well documented.</remarks>
Expr[] GetInterpolant(Expr pf, Expr pat, Params p)
{
Contract.Requires(pf != null);
Contract.Requires(pat != null);
Contract.Requires(p != null);
Contract.Ensures(Contract.Result<Expr>() != null);
CheckContextMatch(pf);
CheckContextMatch(pat);
CheckContextMatch(p);
ASTVector seq = new ASTVector(this, Native.Z3_get_interpolant(nCtx, pf.NativeObject, pat.NativeObject, p.NativeObject));
uint n = seq.Size;
Expr[] res = new Expr[n];
for (uint i = 0; i < n; i++)
res[i] = Expr.Create(this, seq[i].NativeObject);
return res;
}
/// <summary>
/// Computes an interpolant.
/// </summary>
/// <remarks>For more information on interpolation please refer
/// too the function Z3_compute_interpolant in the C/C++ API, which is
/// well documented.</remarks>
Z3_lbool ComputeInterpolant(Expr pat, Params p, out ASTVector interp, out Model model)
{
Contract.Requires(pat != null);
Contract.Requires(p != null);
Contract.Ensures(Contract.ValueAtReturn(out interp) != null);
Contract.Ensures(Contract.ValueAtReturn(out model) != null);
CheckContextMatch(pat);
CheckContextMatch(p);
IntPtr i = IntPtr.Zero, m = IntPtr.Zero;
int r = Native.Z3_compute_interpolant(nCtx, pat.NativeObject, p.NativeObject, ref i, ref m);
interp = new ASTVector(this, i);
model = new Model(this, m);
return (Z3_lbool)r;
}
/// <summary>
/// Return a string summarizing cumulative time used for interpolation.
/// </summary>
/// <remarks>For more information on interpolation please refer
/// too the function Z3_interpolation_profile in the C/C++ API, which is
/// well documented.</remarks>
public string InterpolationProfile()
{
return Native.Z3_interpolation_profile(nCtx);
}
/// <summary>
/// Checks the correctness of an interpolant.
/// </summary>
/// <remarks>For more information on interpolation please refer
/// too the function Z3_check_interpolant in the C/C++ API, which is
/// well documented.</remarks>
public int CheckInterpolant(Expr[] cnsts, uint[] parents, Expr[] interps, out string error, Expr[] theory)
{
Contract.Requires(cnsts.Length == parents.Length);
Contract.Requires(cnsts.Length == interps.Length + 1);
IntPtr n_err_str;
int r = Native.Z3_check_interpolant(nCtx,
(uint)cnsts.Length,
Expr.ArrayToNative(cnsts),
parents,
Expr.ArrayToNative(interps),
out n_err_str,
(uint)theory.Length,
Expr.ArrayToNative(theory));
error = Marshal.PtrToStringAnsi(n_err_str);
return r;
}
/// <summary>
/// Reads an interpolation problem from a file.
/// </summary>
/// <remarks>For more information on interpolation please refer
/// too the function Z3_read_interpolation_problem in the C/C++ API, which is
/// well documented.</remarks>
public int ReadInterpolationProblem(string filename, out Expr[] cnsts, out uint[] parents, out string error, out Expr[] theory)
{
uint num = 0, num_theory = 0;
IntPtr[] n_cnsts;
IntPtr[] n_theory;
IntPtr n_err_str;
int r = Native.Z3_read_interpolation_problem(nCtx, ref num, out n_cnsts, out parents, filename, out n_err_str, ref num_theory, out n_theory);
error = Marshal.PtrToStringAnsi(n_err_str);
cnsts = new Expr[num];
parents = new uint[num];
theory = new Expr[num_theory];
for (int i = 0; i < num; i++)
cnsts[i] = Expr.Create(this, n_cnsts[i]);
for (int i = 0; i < num_theory; i++)
theory[i] = Expr.Create(this, n_theory[i]);
return r;
}
/// <summary>
/// Writes an interpolation problem to a file.
/// </summary>
/// <remarks>For more information on interpolation please refer
/// too the function Z3_write_interpolation_problem in the C/C++ API, which is
/// well documented.</remarks>
public void WriteInterpolationProblem(string filename, Expr[] cnsts, uint[] parents, Expr[] theory)
{
Contract.Requires(cnsts.Length == parents.Length);
Native.Z3_write_interpolation_problem(nCtx, (uint)cnsts.Length, Expr.ArrayToNative(cnsts), parents, filename, (uint)theory.Length, Expr.ArrayToNative(theory));
}
}
}

View file

@ -19,13 +19,12 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\Debug\</OutputPath>
<OutputPath>..\..\..\..\..\cwinter\bugs\z3bugs\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>
</DocumentationFile>
<DocumentationFile>C:\cwinter\bugs\z3bugs\Debug\Microsoft.Z3.XML</DocumentationFile>
<CodeContractsEnableRuntimeChecking>False</CodeContractsEnableRuntimeChecking>
<CodeContractsRuntimeOnlyPublicSurface>False</CodeContractsRuntimeOnlyPublicSurface>
<CodeContractsRuntimeThrowOnFailure>True</CodeContractsRuntimeThrowOnFailure>
@ -140,6 +139,7 @@
<CodeContractsRuntimeCheckingLevel>Full</CodeContractsRuntimeCheckingLevel>
<CodeContractsReferenceAssembly>%28none%29</CodeContractsReferenceAssembly>
<CodeContractsAnalysisWarningLevel>0</CodeContractsAnalysisWarningLevel>
<DocumentationFile>..\x64\Debug\Microsoft.Z3.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>..\x64\external_64\</OutputPath>
@ -193,7 +193,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'external|x64'">
<OutputPath>..\x64\external\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>..\external\Microsoft.Z3.xml</DocumentationFile>
<DocumentationFile>..\x64\external\Microsoft.Z3.XML</DocumentationFile>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
@ -220,7 +220,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release_delaysign|AnyCPU'">
<OutputPath>..\Release_delaysign\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>..\Release_delaysign\Microsoft.Z3.xml</DocumentationFile>
<DocumentationFile>..\Release_delaysign\Microsoft.Z3.XML</DocumentationFile>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
@ -238,7 +238,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release_delaysign|x64'">
<OutputPath>bin\x64\Release_delaysign\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>..\x64\external_64\Microsoft.Z3.xml</DocumentationFile>
<DocumentationFile>bin\x64\Release_delaysign\Microsoft.Z3.XML</DocumentationFile>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
@ -254,7 +254,7 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<OutputPath>..\..\..\..\..\cwinter\bugs\z3bugs\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugType>full</DebugType>
@ -266,11 +266,12 @@
<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>
<DocumentationFile>C:\cwinter\bugs\z3bugs\Debug\Microsoft.Z3.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>..\external\Microsoft.Z3.xml</DocumentationFile>
<DocumentationFile>bin\x86\Release\Microsoft.Z3.xml</DocumentationFile>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
@ -285,7 +286,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'external|x86'">
<OutputPath>bin\x86\external\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>..\external\Microsoft.Z3.xml</DocumentationFile>
<DocumentationFile>bin\x86\external\Microsoft.Z3.XML</DocumentationFile>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
@ -303,7 +304,7 @@
<OutputPath>bin\x86\Release_delaysign\</OutputPath>
<DefineConstants>DELAYSIGN</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>..\Release_delaysign\Microsoft.Z3.xml</DocumentationFile>
<DocumentationFile>bin\x86\Release_delaysign\Microsoft.Z3.XML</DocumentationFile>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
@ -351,6 +352,7 @@
<Compile Include="FuncDecl.cs" />
<Compile Include="FuncInterp.cs" />
<Compile Include="Goal.cs" />
<Compile Include="InterpolationContext.cs" />
<Compile Include="IntExpr.cs" />
<Compile Include="IntNum.cs" />
<Compile Include="IntSort.cs" />
@ -399,4 +401,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>

View file

@ -58,6 +58,16 @@ namespace Microsoft.Z3
Native.Z3_params_set_double(Context.nCtx, NativeObject, name.NativeObject, value);
}
/// <summary>
/// Adds a parameter setting.
/// </summary>
public void Add(Symbol name, string value)
{
Contract.Requires(value != null);
Native.Z3_params_set_symbol(Context.nCtx, NativeObject, name.NativeObject, Context.MkSymbol(value).NativeObject);
}
/// <summary>
/// Adds a parameter setting.
/// </summary>
@ -103,6 +113,16 @@ namespace Microsoft.Z3
Native.Z3_params_set_symbol(Context.nCtx, NativeObject, Context.MkSymbol(name).NativeObject, value.NativeObject);
}
/// <summary>
/// Adds a parameter setting.
/// </summary>
public void Add(string name, string value)
{
Contract.Requires(value != null);
Native.Z3_params_set_symbol(Context.nCtx, NativeObject, Context.MkSymbol(name).NativeObject, Context.MkSymbol(value).NativeObject);
}
/// <summary>
/// A string representation of the parameter set.
/// </summary>

View file

@ -12,7 +12,7 @@ using System.Security.Permissions;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyProduct("Z3")]
[assembly: AssemblyCopyright("Copyright © Microsoft Corporation 2006")]
[assembly: AssemblyCopyright("Copyright (C) 2006-2014 Microsoft Corporation")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@ -36,4 +36,3 @@ using System.Security.Permissions;
// [assembly: AssemblyVersion("4.2.0.0")]
[assembly: AssemblyVersion("4.3.2.0")]
[assembly: AssemblyFileVersion("4.3.2.0")]

View file

@ -132,7 +132,8 @@ namespace Microsoft.Z3
/// <remarks>
/// This API is an alternative to <see cref="Check"/> with assumptions for extracting unsat cores.
/// Both APIs can be used in the same solver. The unsat core will contain a combination
/// of the Boolean variables provided using <see cref="AssertAndTrack"/> and the Boolean literals
/// of the Boolean variables provided using <see cref="AssertAndTrack(BoolExpr[],BoolExpr[])"/>
/// and the Boolean literals
/// provided using <see cref="Check"/> with assumptions.
/// </remarks>
public void AssertAndTrack(BoolExpr[] constraints, BoolExpr[] ps)
@ -156,7 +157,8 @@ namespace Microsoft.Z3
/// <remarks>
/// This API is an alternative to <see cref="Check"/> with assumptions for extracting unsat cores.
/// Both APIs can be used in the same solver. The unsat core will contain a combination
/// of the Boolean variables provided using <see cref="AssertAndTrack"/> and the Boolean literals
/// of the Boolean variables provided using <see cref="AssertAndTrack(BoolExpr[],BoolExpr[])"/>
/// and the Boolean literals
/// provided using <see cref="Check"/> with assumptions.
/// </remarks>
public void AssertAndTrack(BoolExpr constraint, BoolExpr p)
@ -210,7 +212,7 @@ namespace Microsoft.Z3
public Status Check(params Expr[] assumptions)
{
Z3_lbool r;
if (assumptions == null)
if (assumptions == null || assumptions.Length == 0)
r = (Z3_lbool)Native.Z3_solver_check(Context.nCtx, NativeObject);
else
r = (Z3_lbool)Native.Z3_solver_check_assumptions(Context.nCtx, NativeObject, (uint)assumptions.Length, AST.ArrayToNative(assumptions));

View file

@ -74,9 +74,10 @@ namespace Microsoft.Z3
Contract.Requires(name != null);
IntPtr t = IntPtr.Zero;
IntPtr[] f = new IntPtr[numFields];
NativeObject = Native.Z3_mk_tuple_sort(ctx.nCtx, name.NativeObject, numFields,
Symbol.ArrayToNative(fieldNames), AST.ArrayToNative(fieldSorts),
ref t, new IntPtr[numFields]);
ref t, f);
}
#endregion
};

View file

@ -19,6 +19,7 @@ Notes:
using System;
using System.Diagnostics.Contracts;
using System.Threading;
namespace Microsoft.Z3
{
@ -50,8 +51,7 @@ namespace Microsoft.Z3
if (m_ctx != null)
{
m_ctx.refCount--;
if (m_ctx.refCount == 0)
if (Interlocked.Decrement(ref m_ctx.refCount) == 0)
GC.ReRegisterForFinalize(m_ctx);
m_ctx = null;
}
@ -77,7 +77,7 @@ namespace Microsoft.Z3
{
Contract.Requires(ctx != null);
ctx.refCount++;
Interlocked.Increment(ref ctx.refCount);
m_ctx = ctx;
}
@ -85,7 +85,7 @@ namespace Microsoft.Z3
{
Contract.Requires(ctx != null);
ctx.refCount++;
Interlocked.Increment(ref ctx.refCount);
m_ctx = ctx;
IncRef(obj);
m_n_obj = obj;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from AST.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
AST.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;
@ -13,28 +24,12 @@ import com.microsoft.z3.enumerations.Z3_ast_kind;
**/
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.
**/
* <param name="o">another AST</param>
**/
public boolean equals(Object o)
{
AST casted = null;

View file

@ -1,7 +1,19 @@
/**
* Copyright (c) 2012 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
ASTDecRefQueue.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from ASTMap.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
ASTMap.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from ASTVector.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
ASTVector.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from AlgebraicNum.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
AlgebraicNum.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from ApplyResult.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
ApplyResult.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,7 +1,19 @@
/**
* Copyright (c) 2012 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
ApplyResultDecRefQueue.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from ArithExpr.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
* **/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
ArithExpr.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from ArithSort.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
ArithSort.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from ArrayExpr.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
ArrayExpr.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from ArraySort.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
ArraySort.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,7 +1,19 @@
/**
* Copyright (c) 2012 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
AstMapDecRefQueue.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,7 +1,19 @@
/**
* Copyright (c) 2012 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
AstVectorDecRefQueue.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from BitVecExpr.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
BitVecExpr.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from BitVecNum.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
BitVecNum.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;
@ -35,7 +46,7 @@ public class BitVecNum extends BitVecExpr
{
Native.LongPtr res = new Native.LongPtr();
if (Native.getNumeralInt64(getContext().nCtx(), getNativeObject(), res) ^ true)
throw new Z3Exception("Numeral is not an int64");
throw new Z3Exception("Numeral is not a long");
return res.value;
}

View file

@ -1,8 +1,20 @@
/**
* This file was automatically generated from BitVecSort.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
BitVecSort.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;
/**

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from BoolExpr.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
BoolExpr.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from BoolSort.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
BoolSort.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from Constructor.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
Constructor.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from ConstructorList.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
ConstructorList.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from Context.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
Context.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;
@ -2904,27 +2915,13 @@ public class Context extends IDisposable
* configuration parameters can be obtained using the Z3 executable:
* <code>z3.exe -ini?</code> Only a few configuration parameters are mutable
* once the context is created. An exception is thrown when trying to modify
* an immutable parameter. </remarks> <seealso cref="GetParamValue"/>
* an immutable parameter. </remarks>
**/
public void updateParamValue(String id, String value) throws Z3Exception
{
Native.updateParamValue(nCtx(), id, value);
}
/**
* Get a configuration parameter. <remarks> Returns null if the parameter
* value does not exist. </remarks> <seealso cref="UpdateParamValue"/>
**/
public String getParamValue(String id) throws Z3Exception
{
Native.StringPtr res = new Native.StringPtr();
boolean r = Native.getParamValue(nCtx(), id, res);
if (!r)
return null;
else
return res.value;
}
long m_ctx = 0;
long nCtx()

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from DatatypeExpr.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
DatatypeExpr.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from DatatypeSort.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
DatatypeSort.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from EnumSort.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
EnumSort.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

File diff suppressed because it is too large Load diff

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from FiniteDomainSort.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
FiniteDomainSort.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from Fixedpoint.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
Fixedpoint.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,7 +1,19 @@
/**
* Copyright (c) 2012 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
FixedpointDecRefQueue.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from FuncDecl.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
FuncDecl.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from FuncInterp.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
FuncInterp.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,7 +1,19 @@
/**
* Copyright (c) 2012 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
FuncInterpDecRefQueue.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,7 +1,19 @@
/**
* Copyright (c) 2012 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
FuncInterpEntryDecRefQueue.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,7 +1,19 @@
/**
* Global.java
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
Global.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;
@ -38,8 +50,7 @@ public final class Global
/**
* Get a global (or module) parameter.
* <remarks>
* Returns null if the parameter <param name="id"/> does not exist.
* The caller must invoke #Z3_global_param_del_value to delete the value returned at \c param_value.
* Returns null if the parameter <param name="id">parameter id</param> does not exist.
* This function cannot be invoked simultaneously from different threads without synchronization.
* The result string stored in param_value is stored in a shared location.
* </remarks>
@ -58,7 +69,7 @@ public final class Global
* <remarks>
* This command will not affect already created objects (such as tactics and solvers)
* </remarks>
* @seealso SetParameter
* <seealso cref="SetParameter"/>
**/
public static void resetParameters()
{

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from Goal.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
Goal.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,7 +1,19 @@
/**
* Copyright (c) 2012 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
GoalDecRefQueue.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from IDecRefQueue.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
IDecRefQueue.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from IntExpr.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
IntExpr.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from IntNum.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
IntNum.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from IntSort.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
IntSort.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from IntSymbol.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
IntSymbol.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -0,0 +1,183 @@
/**
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
InterpolationContext.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;
import java.util.Map;
import java.lang.String;
import com.microsoft.z3.Native.IntPtr;
import com.microsoft.z3.Native.UIntArrayPtr;
import com.microsoft.z3.enumerations.Z3_lbool;
/** <summary>
* The InterpolationContext is suitable for generation of interpolants.
* </summary>
* <remarks>For more information on interpolation please refer
* too the C/C++ API, which is well documented.</remarks>
**/
public class InterpolationContext extends Context
{
/**
* Constructor.
**/
public InterpolationContext() throws Z3Exception
{
m_ctx = Native.mkInterpolationContext(0);
initContext();
}
/**
* Constructor.
*
* <remarks><seealso cref="Context.Context(Dictionary&lt;string, string&gt;)"/></remarks>
**/
public InterpolationContext(Map<String, String> settings) throws Z3Exception
{
long cfg = Native.mkConfig();
for (Map.Entry<String, String> kv : settings.entrySet())
Native.setParamValue(cfg, kv.getKey(), kv.getValue());
m_ctx = Native.mkInterpolationContext(cfg);
Native.delConfig(cfg);
initContext();
}
/**
* Create an expression that marks a formula position for interpolation.
* @throws Z3Exception
**/
public BoolExpr MkInterpolant(BoolExpr a) throws Z3Exception
{
checkContextMatch(a);
return new BoolExpr(this, Native.mkInterpolant(nCtx(), a.getNativeObject()));
}
/**
* Computes an interpolant.
* <remarks>For more information on interpolation please refer
* too the function Z3_get_interpolant in the C/C++ API, which is
* well documented.</remarks>
* @throws Z3Exception
**/
Expr[] GetInterpolant(Expr pf, Expr pat, Params p) throws Z3Exception
{
checkContextMatch(pf);
checkContextMatch(pat);
checkContextMatch(p);
ASTVector seq = new ASTVector(this, Native.getInterpolant(nCtx(), pf.getNativeObject(), pat.getNativeObject(), p.getNativeObject()));
int n = seq.size();
Expr[] res = new Expr[n];
for (int i = 0; i < n; i++)
res[i] = Expr.create(this, seq.get(i).getNativeObject());
return res;
}
/**
* Computes an interpolant.
* <remarks>For more information on interpolation please refer
* too the function Z3_compute_interpolant in the C/C++ API, which is
* well documented.</remarks>
* @throws Z3Exception
**/
Z3_lbool ComputeInterpolant(Expr pat, Params p, ASTVector interp, Model model) throws Z3Exception
{
checkContextMatch(pat);
checkContextMatch(p);
Native.LongPtr n_i = new Native.LongPtr();
Native.LongPtr n_m = new Native.LongPtr();
int r = Native.computeInterpolant(nCtx(), pat.getNativeObject(), p.getNativeObject(), n_i, n_m);
interp = new ASTVector(this, n_i.value);
model = new Model(this, n_m.value);
return Z3_lbool.fromInt(r);
}
/// <summary>
/// Return a string summarizing cumulative time used for interpolation.
/// </summary>
/// <remarks>For more information on interpolation please refer
/// too the function Z3_interpolation_profile in the C/C++ API, which is
/// well documented.</remarks>
public String InterpolationProfile() throws Z3Exception
{
return Native.interpolationProfile(nCtx());
}
/// <summary>
/// Checks the correctness of an interpolant.
/// </summary>
/// <remarks>For more information on interpolation please refer
/// too the function Z3_check_interpolant in the C/C++ API, which is
/// well documented.</remarks>
public int CheckInterpolant(Expr[] cnsts, int[] parents, Expr[] interps, String error, Expr[] theory) throws Z3Exception
{
Native.StringPtr n_err_str = new Native.StringPtr();
int r = Native.checkInterpolant(nCtx(),
cnsts.length,
Expr.arrayToNative(cnsts),
parents,
Expr.arrayToNative(interps),
n_err_str,
theory.length,
Expr.arrayToNative(theory));
error = n_err_str.value;
return r;
}
/// <summary>
/// Reads an interpolation problem from a file.
/// </summary>
/// <remarks>For more information on interpolation please refer
/// too the function Z3_read_interpolation_problem in the C/C++ API, which is
/// well documented.</remarks>
public int ReadInterpolationProblem(String filename, Expr[] cnsts, int[] parents, String error, Expr[] theory) throws Z3Exception
{
Native.IntPtr n_num = new Native.IntPtr();
Native.IntPtr n_num_theory = new Native.IntPtr();
Native.ObjArrayPtr n_cnsts = new Native.ObjArrayPtr();
Native.UIntArrayPtr n_parents = new Native.UIntArrayPtr();
Native.ObjArrayPtr n_theory = new Native.ObjArrayPtr();
Native.StringPtr n_err_str = new Native.StringPtr();
int r = Native.readInterpolationProblem(nCtx(), n_num, n_cnsts, n_parents, filename, n_err_str, n_num_theory, n_theory);
int num = n_num.value;
int num_theory = n_num_theory.value;
error = n_err_str.value;
cnsts = new Expr[num];
parents = new int[num];
theory = new Expr[num_theory];
for (int i = 0; i < num; i++)
{
cnsts[i] = Expr.create(this, n_cnsts.value[i]);
parents[i] = n_parents.value[i];
}
for (int i = 0; i < num_theory; i++)
theory[i] = Expr.create(this, n_theory.value[i]);
return r;
}
/// <summary>
/// Writes an interpolation problem to a file.
/// </summary>
/// <remarks>For more information on interpolation please refer
/// too the function Z3_write_interpolation_problem in the C/C++ API, which is
/// well documented.</remarks>
public void WriteInterpolationProblem(String filename, Expr[] cnsts, int[] parents, String error, Expr[] theory) throws Z3Exception
{
Native.writeInterpolationProblem(nCtx(), cnsts.length, Expr.arrayToNative(cnsts), parents, filename, theory.length, Expr.arrayToNative(theory));
}
}

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from ListSort.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
ListSort.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from Log.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
Log.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from Model.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
Model.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,7 +1,19 @@
/**
* Copyright (c) 2012 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
ModelDecRefQueue.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from ParamDescrs.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
ParamDescrs.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,7 +1,19 @@
/**
* Copyright (c) 2012 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
ParamDescrsDecRefQueue.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,20 @@
/**
* This file was automatically generated from Params.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
Params.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;
@ -28,6 +40,17 @@ public class Params extends Z3Object
Native.paramsSetDouble(getContext().nCtx(), getNativeObject(),
name.getNativeObject(), value);
}
/**
* Adds a parameter setting.
**/
public void add(Symbol name, String value) throws Z3Exception
{
Native.paramsSetSymbol(getContext().nCtx(), getNativeObject(),
name.getNativeObject(),
getContext().mkSymbol(value).getNativeObject());
}
/**
* Adds a parameter setting.
@ -75,6 +98,17 @@ public class Params extends Z3Object
.mkSymbol(name).getNativeObject(), value.getNativeObject());
}
/**
* Adds a parameter setting.
**/
public void add(String name, String value) throws Z3Exception
{
Native.paramsSetSymbol(getContext().nCtx(), getNativeObject(),
getContext().mkSymbol(name).getNativeObject(),
getContext().mkSymbol(value).getNativeObject());
}
/**
* A string representation of the parameter set.
**/

View file

@ -1,7 +1,19 @@
/**
* Copyright (c) 2012 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
ParamDecRefQueue.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from Pattern.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
Pattern.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from Probe.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
Probe.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,7 +1,19 @@
/**
* Copyright (c) 2012 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
ProbeDecRefQueue.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from Quantifier.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
Quantifier.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,3 +1,6 @@
Java bindings
-------------
The Java bindings will be included in the Z3 build if it is configured with
the option --java to python scripts/mk_make.py. This will produce the
com.microsoft.z3.jar package in the build directory.

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from RatNum.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
RatNum.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from RealExpr.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
RealExpr.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from RealSort.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
RealSort.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from RelationSort.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
RelationSort.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from SetSort.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
SetSort.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from Solver.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
Solver.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,7 +1,19 @@
/**
* Copyright (c) 2012 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
SolverDecRefQueue.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from Sort.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
Sort.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;
@ -14,27 +25,10 @@ import com.microsoft.z3.enumerations.Z3_sort_kind;
**/
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>
* Equality operator for objects of type Sort. <param name="o"/>
*
* @return
**/

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from Statistics.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
Statistics.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,7 +1,19 @@
/**
* Copyright (c) 2012 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
StatisticsDecRefQueue.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from Status.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
Status.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;
@ -12,7 +23,7 @@ package com.microsoft.z3;
public enum Status
{
// / Used to signify an unsatisfiable status.
UNSATISFIABLE(1),
UNSATISFIABLE(-1),
// / Used to signify an unknown status.
UNKNOWN(0),

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from StringSymbol.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
StringSymbol.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from Symbol.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
Symbol.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from Tactic.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
Tactic.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,7 +1,19 @@
/**
* Copyright (c) 2012 Microsoft Corporation
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
TacticDecRefQueue.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from TupleSort.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
TupleSort.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from UninterpretedSort.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
UninterpretedSort.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from Version.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
Version.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from Z3Exception.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
Z3Exception.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,8 +1,19 @@
/**
* This file was automatically generated from Z3Object.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
Copyright (c) 2012-2014 Microsoft Corporation
Module Name:
Z3Object.java
Abstract:
Author:
@author Christoph Wintersteiger (cwinter) 2012-03-15
Notes:
**/
package com.microsoft.z3;

View file

@ -1,2 +1,2 @@
Manifest-Version: 1.0
Created-By: 4.3.0 (Microsoft Research LTD.)
Created-By: 4.3.2 (Microsoft Research LTD.)

View file

@ -1,463 +0,0 @@
######################################################
# Copyright (c) 2012 Microsoft Corporation
#
# Auxiliary scripts for generating Java bindings
# from the managed API.
#
# Author: Christoph M. Wintersteiger (cwinter)
######################################################
###
# DO NOT USE THIS SCRIPT!
# This script creates a rough draft of a Java API from
# the managed API, but does not automated the process.
###
CS="../dotnet/"
EXT=".cs"
EXCLUDE=["Enumerations.cs", "Native.cs", "AssemblyInfo.cs"]
OUTDIR="com/Microsoft/Z3/"
ENUMS_FILE = "Enumerations.cs"
import os
import fileinput
import string
import re
EXCLUDE_METHODS = [ [ "Context.cs", "public Expr MkNumeral(ulong" ],
[ "Context.cs", "public Expr MkNumeral(uint" ],
[ "Context.cs", "public RatNum MkReal(ulong" ],
[ "Context.cs", "public RatNum MkReal(uint" ],
[ "Context.cs", "public IntNum MkInt(ulong" ],
[ "Context.cs", "public IntNum MkInt(uint" ],
[ "Context.cs", "public BitVecNum MkBV(ulong" ],
[ "Context.cs", "public BitVecNum MkBV(uint" ],
]
ENUMS = []
def mk_java_bindings():
print "Generating Java bindings (from C# bindings in " + CS + ")..."
print "Finding enumerations in " + ENUMS_FILE + "..."
find_enums(ENUMS_FILE)
for root, dirs, files in os.walk(CS):
for fn in files:
if not fn in EXCLUDE and fn.endswith(EXT):
translate(fn)
def subst_getters(s, getters):
for g in getters:
s = s.replace(g, g + "()")
def type_replace(s):
s = s.replace(" bool", " boolean")
s = s.replace("(bool", "(boolean")
s = s.replace("uint", "int")
s = s.replace("ulong", "long")
s = s.replace("string", "String")
s = s.replace("IntPtr", "long")
s = s.replace("Dictionary<", "Map<")
s = s.replace("UInt64", "long")
s = s.replace("Int64", "long")
s = s.replace("List<long>", "LinkedList<Long>")
s = s.replace("System.Exception", "Exception")
return s
def rename_native(s):
while s.find("Native.Z3") != -1:
i0 = s.find("Native.Z3")
i1 = s.find("(", i0)
c0 = s[:i0]
c1 = s[i0:i1]
c1 = c1.replace("Native.Z3_", "Native.")
c2 = s[i1:]
lc_callback = lambda pat: pat.group("id").upper()
c1 = re.sub("_(?P<id>\w)", lc_callback, c1)
s = c0 + c1 + c2
return s
def find_enums(fn):
for line in fileinput.input(os.path.join(CS, fn)):
s = string.rstrip(string.lstrip(line))
if s.startswith("public enum"):
ENUMS.append(s.split(" ")[2])
def enum_replace(line):
for e in ENUMS:
if line.find("case") != -1:
line = line.replace(e + ".", "")
elif line.find("== (int)") != -1 or line.find("!= (int)") != -1:
line = re.sub("\(int\)" + e + "\.(?P<id>[A-Z0-9_]*)", e + ".\g<id>.toInt()", line)
elif line.find("==") != -1 or line.find("!=") != -1:
line = re.sub(e + "\.(?P<id>[A-Z0-9_]*)", e + ".\g<id>", line)
else:
# line = re.sub("\(\(" + e + "\)(?P<rest>.*\(.*)\)", "(" + e + ".values()[\g<rest>])", line)
line = re.sub("\(" + e + "\)(?P<rest>.*\(.*\))", e + ".fromInt(\g<rest>)", line)
return line
def replace_generals(a):
a = re.sub(" NativeObject", " NativeObject()", a)
a = re.sub("\.NativeObject", ".NativeObject()", a)
a = re.sub("(?P<h>[\.\(])Id", "\g<h>Id()", a)
a = a.replace("(Context ==", "(Context() ==")
a = a.replace("(Context,", "(Context(),")
a = a.replace("Context.", "Context().")
a = a.replace(".nCtx", ".nCtx()")
a = a.replace("(nCtx", "(nCtx()")
a = re.sub("Context\(\).(?P<id>[^_]*)_DRQ", "Context().\g<id>_DRQ()", a)
a = re.sub("ASTKind", "ASTKind()", a)
a = re.sub("IsExpr(?P<f>[ ;])", "IsExpr()\g<f>", a)
a = re.sub("IsNumeral(?P<f>[ ;])", "IsNumeral()\g<f>", a)
a = re.sub("IsInt(?P<f>[ ;])", "IsInt()\g<f>", a)
a = re.sub("IsReal(?P<f>[ ;])", "IsReal()\g<f>", a)
a = re.sub("IsVar(?P<f>[ ;\)])", "IsVar()\g<f>", a)
a = re.sub("FuncDecl.DeclKind", "FuncDecl().DeclKind()", a)
a = re.sub("FuncDecl.DomainSize", "FuncDecl().DomainSize()", a)
a = re.sub("(?P<h>[=&]) Num(?P<id>[a-zA-Z]*)", "\g<h> Num\g<id>()", a)
a = re.sub("= Denominator", "= Denominator()", a)
a = re.sub(", BoolSort(?P<f>[\)\.])", ", BoolSort()\g<f>", a)
a = re.sub(", RealSort(?P<f>[\)\.])", ", RealSort()\g<f>", a)
a = re.sub(", IntSort(?P<f>[\)\.])", ", IntSort()\g<f>", a)
a = a.replace("? 1 : 0", "? true : false")
if a.find("Native.") != -1 and a.find("!= 0") != -1:
a = a.replace("!= 0", "")
if a.find("Native.") != -1 and a.find("== 0") != -1:
a = a.replace("== 0", "^ true")
return a
def translate(filename):
tgtfn = OUTDIR + filename.replace(EXT, ".java")
print "Translating " + filename + " to " + tgtfn
tgt = open(tgtfn, "w")
in_header = 0
in_class = 0
in_static_class = 0
in_javadoc = 0
lastindent = 0
skip_brace = 0
in_getter = ""
in_getter_type = ""
in_unsupported = 0
getters = []
in_bracket_op = 0
in_getter_get = 0
in_getter_set = 0
had_ulong_res = 0
in_enum = 0
missing_foreach_brace = 0
foreach_opened_brace = 0
for line in fileinput.input(os.path.join(CS, filename)):
s = string.rstrip(string.lstrip(line))
if in_javadoc:
if s.startswith("///"):
lastindent = line.find(s);
if s.startswith("/// </summary>"):
pass
else:
a = line
a = a.replace("<c>", "<code>")
a = a.replace("</c>", "</code>")
a = a.replace("///"," *")
a = a.replace("<returns>","@return ")
a = a.replace("</returns>","")
tgt.write(a)
else:
t = ""
for i in range(0, lastindent):
t += " "
tgt.write(t + " **/\n")
in_javadoc = 0
# for i in range(0, len(EXCLUDE_METHODS)):
# if filename == EXCLUDE_METHODS[i][0] and s.startswith(EXCLUDE_METHODS[i][1]):
# tgt.write(t + "/* Not translated because it would translate to a function with clashing types. */\n")
# in_unsupported = 1
# break
if in_unsupported:
if s == "}":
in_unsupported = 0
elif not in_javadoc:
if not in_header and s.find("/*++") != -1:
in_header = 1
tgt.write("/**\n")
elif in_header and s.startswith("--*/"):
in_header = 0
tgt.write(" * This file was automatically generated from " + filename + " \n")
tgt.write(" **/\n")
tgt.write("\npackage com.Microsoft.Z3;\n\n")
tgt.write("import java.math.BigInteger;\n")
tgt.write("import java.util.*;\n")
tgt.write("import java.lang.Exception;\n")
tgt.write("import com.Microsoft.Z3.Enumerations.*;\n")
elif in_header == 1:
# tgt.write(" * " + line.replace(filename, tgtfn))
pass
elif s.startswith("using"):
if s.find("System.Diagnostics.Contracts") == -1:
tgt.write("/* " + s + " */\n")
elif s.startswith("namespace"):
pass
elif s.startswith("public") and s.find("operator") != -1 and (s.find("==") != -1 or s.find("!=") != -1):
t = ""
for i in range(0, line.find(s)+1):
t += " "
tgt.write(t + "/* Overloaded operators are not translated. */\n")
in_unsupported = 1
elif s.startswith("public enum"):
tgt.write(line.replace("enum", "class"))
in_enum = 1
elif in_enum == 1:
if s == "}":
tgt.write(line)
in_enum = 0
else:
line = re.sub("(?P<id>.*)\W*=\W*(?P<val>[^\n,])", "public static final int \g<id> = \g<val>;", line)
tgt.write(line.replace(",",""))
elif s.startswith("public class") or s.startswith("internal class") or s.startswith("internal abstract class"):
a = line.replace(":", "extends").replace("internal ", "")
a = a.replace(", IComparable", "")
a = type_replace(a)
tgt.write(a)
in_class = 1
in_static_class = 0
elif s.startswith("public static class") or s.startswith("abstract class"):
tgt.write(line.replace(":", "extends").replace("static", "final"))
in_class = 1
in_static_class = 1
elif s.startswith("/// <summary>"):
tgt.write(line.replace("/// <summary>", "/**"))
in_javadoc = 1
elif skip_brace and s == "{":
skip_brace = 0
elif ((s.find("public") != -1 or s.find("protected") != -1) and s.find("class") == -1 and s.find("event") == -1 and s.find("(") == -1) or s.startswith("internal virtual IntPtr NativeObject") or s.startswith("internal Context Context"):
if (s.startswith("new")):
s = s[3:]
s = s.replace("internal virtual", "")
s = s.replace("internal", "")
tokens = s.split(" ")
# print "TOKENS: " + str(len(tokens))
if len(tokens) == 3:
in_getter = tokens[2]
in_getter_type = type_replace((tokens[0] + " " + tokens[1]))
if in_static_class:
in_getter_type = in_getter_type.replace("static", "")
lastindent = line.find(s)
skip_brace = 1
getters.append(in_getter)
elif len(tokens) == 4:
if tokens[2].startswith("this["):
in_bracket_op = 1
in_getter = type_replace(tokens[2]).replace("this[", "get(")
in_getter += " " + tokens[3].replace("]", ")")
in_getter_type = type_replace(tokens[0] + " " + tokens[1])
else:
in_getter = tokens[3]
in_getter_type = type_replace(tokens[0] + " " + tokens[1] + " " + tokens[2])
if in_static_class:
in_getter_type = in_getter_type.replace("static", "")
lastindent = line.find(s)
skip_brace = 1
getters.append(in_getter)
else:
in_getter = tokens[2]
in_getter_type = type_replace(tokens[0] + " " + tokens[1])
if tokens[2].startswith("this["):
lastindent = line.find(s)
t = ""
for i in range(0, lastindent): t += " "
tgt.write(t + "/* operator this[] not translated */\n ")
in_unsupported = 1
else:
if in_static_class:
in_getter_type = in_getter_type.replace("static", "")
rest = s[s.find("get ") + 4:-1]
subst_getters(rest, getters)
rest = type_replace(rest)
rest = rename_native(rest)
rest = replace_generals(rest)
rest = enum_replace(rest)
t = ""
for i in range(0, lastindent):
t += " "
tgt.write(t + in_getter_type + " " + in_getter + "() " + rest + "\n")
if rest.find("}") == -1:
in_getter_get = 1
else:
getters.append(in_getter)
in_getter = ""
in_getter_type = ""
print "ACC: " + s + " --> " + in_getter
elif s.find("{ get {") != -1:
line = type_replace(line)
line = line.replace("internal ", "")
d = line[0:line.find("{ get")]
rest = line[line.find("{ get")+5:]
rest = rest.replace("} }", "}")
rest = re.sub("Contract.\w+\([\s\S]*\);", "", rest)
subst_getters(rest, getters)
rest = rename_native(rest)
rest = replace_generals(rest)
rest = enum_replace(rest)
if in_bracket_op:
tgt.write(d + rest)
else:
tgt.write(d + "()" + rest)
print "ACC: " + s + " --> " + in_getter
elif in_getter != "" and s.startswith("get"):
t = ""
for i in range(0, lastindent):
t += " "
if len(s) > 3: rest = s[3:]
else: rest = ""
subst_getters(rest, getters)
rest = type_replace(rest)
rest = rename_native(rest)
rest = replace_generals(rest)
rest = enum_replace(rest)
if in_bracket_op:
tgt.write(t + in_getter_type + " " + in_getter + " " + rest + "\n")
else:
tgt.write(t + in_getter_type + " " + in_getter + "() " + rest + "\n")
if rest.find("}") == -1:
in_getter_get = 1
elif in_getter != "" and s.startswith("set"):
t = ""
for i in range(0, lastindent):
t += " "
if len(s) > 3: rest = type_replace(s[3:])
else: rest = ""
subst_getters(rest, getters)
rest = rest.replace("(Integer)value", "Integer(value)")
rest = type_replace(rest)
rest = rename_native(rest)
rest = replace_generals(rest)
rest = enum_replace(rest)
ac_acc = in_getter_type[:in_getter_type.find(' ')]
ac_type = in_getter_type[in_getter_type.find(' ')+1:]
if in_bracket_op:
in_getter = in_getter.replace("get", "set").replace(")", "")
tgt.write(t + ac_acc + " void " + in_getter + ", " + ac_type + " value) " + rest + "\n")
else:
tgt.write(t + ac_acc + " void set" + in_getter + "(" + ac_type + " value) " + rest + "\n")
if rest.find("}") == -1:
in_getter_set = 1
elif in_getter != "" and in_getter_get == 1 and s == "}":
tgt.write(line)
in_getter_get = 0
elif in_getter != "" and in_getter_set == 1 and s == "}":
tgt.write(line)
in_getter_set = 0
elif in_getter != "" and in_getter_get == 0 and in_getter_set == 0 and s == "}":
in_getter = ""
in_getter_type == ""
in_bracket_op = 0
skip_brace = 0
elif s.startswith("uint ") and s.find("=") == -1:
line = line.replace("uint", "Integer", line)
line = re.sub("(?P<n>\w+)(?P<c>[,;])", "\g<n>\g<c>", line)
tgt.write(line);
elif (not in_class and (s.startswith("{") or s.startswith("}"))) or s.startswith("[") or s.startswith("#"):
# tgt.write("// Skipping: " + s)
pass
elif line == "}\n":
pass
else:
# indent = line.find(s)
# tgt.write("// LINE: " + line)
if line.find(": base") != -1:
line = re.sub(": base\((?P<p>[^\{]*)\)", "{ super(\g<p>);", line)
line = line[4:]
obraces = line.count("{")
cbraces = line.count("}")
mbraces = obraces - cbraces
# tgt.write("// obraces = " + str(obraces) + "\n")
if obraces == 1:
skip_brace = 1
else:
for i in range(0, mbraces):
line = line.replace("\n", "}\n")
if (s.find("public") != -1 or s.find("protected") != -1 or s.find("internal") != -1) and s.find("(") != -1:
line = re.sub(" = [\w.]+(?P<d>[,;\)])", "\g<d>", line)
a = type_replace(line)
a = enum_replace(a)
a = re.sub("(?P<d>[\(, ])params ", "\g<d>", a)
a = a.replace("base.", "super.")
a = re.sub("Contract.\w+\([\s\S]*\);", "", a)
a = rename_native(a)
a = re.sub("~\w+\(\)", "protected void finalize()", a)
if missing_foreach_brace == 1:
# a = a.replace("\n", " // checked " + str(foreach_opened_brace) + "\n")
if foreach_opened_brace == 0 and a.find("{") != -1:
foreach_opened_brace = 1
elif foreach_opened_brace == 0 and a.find("}") == -1:
a = a.replace("\n", "}}\n")
foreach_opened_brace = 0
missing_foreach_brace = 0
elif foreach_opened_brace == 1 and a.find("}") != -1:
a = a.replace("\n", "}}\n")
foreach_opened_brace = 0
missing_foreach_brace = 0
# if a.find("foreach") != -1:
# missing_foreach_brace = 1
# a = re.sub("foreach\s*\((?P<t>[\w <>,]+)\s+(?P<i>\w+)\s+in\s+(?P<w>\w+)\)",
# "{ Iterator fe_i = \g<w>.iterator(); while (fe_i.hasNext()) { \g<t> \g<i> = (long)fe_i.next(); ",
# a)
a = re.sub("foreach\s*\((?P<t>[\w <>,]+)\s+(?P<i>\w+)\s+in\s+(?P<w>\w+)\)",
"for (\g<t> \g<i>: \g<w>)",
a)
if a.find("long o: m_queue") != -1:
a = a.replace("long", "Long")
a = a.replace("readonly ", "")
a = a.replace("const ", "final ")
a = a.replace("String ToString", "String toString")
a = a.replace(".ToString", ".toString")
a = a.replace("internal ", "")
a = a.replace("new static", "static")
a = a.replace("new public", "public")
a = a.replace("override ", "")
a = a.replace("virtual ", "")
a = a.replace("o as AST", "(AST) o")
a = a.replace("o as Sort", "(Sort) o")
a = a.replace("other as AST", "(AST) other")
a = a.replace("o as FuncDecl", "(FuncDecl) o")
a = a.replace("IntPtr obj", "long obj")
a = a.replace("IntPtr o", "long o")
a = a.replace("new long()", "0")
a = a.replace("long.Zero", "0")
a = a.replace("object o", "Object o")
a = a.replace("object other", "Object other")
a = a.replace("IntPtr res = IntPtr.Zero;", "Native.IntPtr res = new Native.IntPtr();")
a = a.replace("out res", "res")
a = a.replace("GC.ReRegisterForFinalize(m_ctx);", "")
a = a.replace("GC.SuppressFinalize(this);", "")
a = a.replace(".Length", ".length")
a = a.replace("m_queue.Count", "m_queue.size()")
a = a.replace("m_queue.Add", "m_queue.add")
a = a.replace("m_queue.Clear", "m_queue.clear")
a = a.replace("for (long ", "for (int ")
a = a.replace("ReferenceEquals(Context, ctx)", "Context() == ctx")
a = a.replace("BigInteger.Parse", "new BigInteger")
if had_ulong_res == 0 and a.find("ulong res = 0") != -1:
a = a.replace("ulong res = 0;", "LongPtr res = new LongPtr();")
elif had_ulong_res == 1:
a = a.replace("ref res)", "res)")
if a.find("return res;") != -1:
a = a.replace("return res;", "return res.value;")
had_ulong_res = 0
a = a.replace("lock (", "synchronized (")
if in_static_class:
a = a.replace("static", "")
a = re.sub("ref (?P<id>\w+)", "\g<id>", a)
subst_getters(a, getters)
a = re.sub("NativeObject = (?P<rest>.*);", "setNativeObject(\g<rest>);", a)
a = replace_generals(a)
tgt.write(a)
tgt.close()
mk_java_bindings()

Some files were not shown because too many files have changed in this diff Show more