3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-24 01:25:31 +00:00
This commit is contained in:
Yatao Li 2018-12-29 16:27:00 +08:00
commit f5b874e0a3
587 changed files with 16270 additions and 9645 deletions

View file

@ -79,23 +79,23 @@ extern "C" {
_c->autil().is_irrational_algebraic_numeral(to_expr(a)));
}
Z3_bool Z3_API Z3_algebraic_is_value(Z3_context c, Z3_ast a) {
bool Z3_API Z3_algebraic_is_value(Z3_context c, Z3_ast a) {
Z3_TRY;
LOG_Z3_algebraic_is_value(c, a);
RESET_ERROR_CODE();
return Z3_algebraic_is_value_core(c, a) ? Z3_TRUE : Z3_FALSE;
Z3_CATCH_RETURN(Z3_FALSE);
return Z3_algebraic_is_value_core(c, a);
Z3_CATCH_RETURN(false);
}
Z3_bool Z3_API Z3_algebraic_is_pos(Z3_context c, Z3_ast a) {
bool Z3_API Z3_algebraic_is_pos(Z3_context c, Z3_ast a) {
return Z3_algebraic_sign(c, a) > 0;
}
Z3_bool Z3_API Z3_algebraic_is_neg(Z3_context c, Z3_ast a) {
bool Z3_API Z3_algebraic_is_neg(Z3_context c, Z3_ast a) {
return Z3_algebraic_sign(c, a) < 0;
}
Z3_bool Z3_API Z3_algebraic_is_zero(Z3_context c, Z3_ast a) {
bool Z3_API Z3_algebraic_is_zero(Z3_context c, Z3_ast a) {
return Z3_algebraic_sign(c, a) == 0;
}
@ -283,32 +283,32 @@ extern "C" {
r = _am.IRAT_PRED(av, bv); \
} \
} \
return r ? Z3_TRUE : Z3_FALSE;
return r;
Z3_bool Z3_API Z3_algebraic_lt(Z3_context c, Z3_ast a, Z3_ast b) {
bool Z3_API Z3_algebraic_lt(Z3_context c, Z3_ast a, Z3_ast b) {
Z3_TRY;
LOG_Z3_algebraic_lt(c, a, b);
RESET_ERROR_CODE();
CHECK_IS_ALGEBRAIC(a, 0);
CHECK_IS_ALGEBRAIC(b, 0);
BIN_PRED(<,lt);
Z3_CATCH_RETURN(Z3_FALSE);
Z3_CATCH_RETURN(false);
}
Z3_bool Z3_API Z3_algebraic_gt(Z3_context c, Z3_ast a, Z3_ast b) {
bool Z3_API Z3_algebraic_gt(Z3_context c, Z3_ast a, Z3_ast b) {
return Z3_algebraic_lt(c, b, a);
}
Z3_bool Z3_API Z3_algebraic_le(Z3_context c, Z3_ast a, Z3_ast b) {
bool Z3_API Z3_algebraic_le(Z3_context c, Z3_ast a, Z3_ast b) {
return !Z3_algebraic_lt(c, b, a);
}
Z3_bool Z3_API Z3_algebraic_ge(Z3_context c, Z3_ast a, Z3_ast b) {
bool Z3_API Z3_algebraic_ge(Z3_context c, Z3_ast a, Z3_ast b) {
return !Z3_algebraic_lt(c, a, b);
}
Z3_bool Z3_API Z3_algebraic_eq(Z3_context c, Z3_ast a, Z3_ast b) {
bool Z3_API Z3_algebraic_eq(Z3_context c, Z3_ast a, Z3_ast b) {
Z3_TRY;
LOG_Z3_algebraic_eq(c, a, b);
RESET_ERROR_CODE();
@ -318,7 +318,7 @@ extern "C" {
Z3_CATCH_RETURN(0);
}
Z3_bool Z3_API Z3_algebraic_neq(Z3_context c, Z3_ast a, Z3_ast b) {
bool Z3_API Z3_algebraic_neq(Z3_context c, Z3_ast a, Z3_ast b) {
return !Z3_algebraic_eq(c, a, b);
}

View file

@ -119,9 +119,9 @@ extern "C" {
Z3_CATCH_RETURN(nullptr);
}
Z3_bool Z3_API Z3_is_algebraic_number(Z3_context c, Z3_ast a) {
bool Z3_API Z3_is_algebraic_number(Z3_context c, Z3_ast a) {
LOG_Z3_is_algebraic_number(c, a);
return mk_c(c)->autil().is_irrational_algebraic_numeral(to_expr(a)) ? Z3_TRUE : Z3_FALSE;
return mk_c(c)->autil().is_irrational_algebraic_numeral(to_expr(a));
}
Z3_ast Z3_API Z3_get_algebraic_number_lower(Z3_context c, Z3_ast a, unsigned precision) {

View file

@ -33,11 +33,15 @@ Revision History:
#include "ast/rewriter/th_rewriter.h"
#include "ast/rewriter/var_subst.h"
#include "ast/rewriter/expr_safe_replace.h"
#include "ast/rewriter/recfun_replace.h"
#include "ast/rewriter/seq_rewriter.h"
#include "ast/pp.h"
#include "util/scoped_ctrl_c.h"
#include "util/cancel_eh.h"
#include "util/scoped_timer.h"
#include "ast/pp_params.hpp"
#include "ast/expr_abstract.h"
extern bool is_numeral_sort(Z3_context c, Z3_sort ty);
@ -70,7 +74,7 @@ extern "C" {
Z3_CATCH_RETURN(nullptr);
}
Z3_bool Z3_API Z3_is_eq_sort(Z3_context c, Z3_sort s1, Z3_sort s2) {
bool Z3_API Z3_is_eq_sort(Z3_context c, Z3_sort s1, Z3_sort s2) {
RESET_ERROR_CODE();
return s1 == s2;
}
@ -85,12 +89,12 @@ extern "C" {
Z3_CATCH_RETURN(nullptr);
}
Z3_bool Z3_API Z3_is_eq_ast(Z3_context c, Z3_ast s1, Z3_ast s2) {
bool Z3_API Z3_is_eq_ast(Z3_context c, Z3_ast s1, Z3_ast s2) {
RESET_ERROR_CODE();
return s1 == s2;
}
Z3_bool Z3_API Z3_is_eq_func_decl(Z3_context c, Z3_func_decl s1, Z3_func_decl s2) {
bool Z3_API Z3_is_eq_func_decl(Z3_context c, Z3_func_decl s1, Z3_func_decl s2) {
RESET_ERROR_CODE();
return s1 == s2;
}
@ -110,6 +114,55 @@ extern "C" {
Z3_CATCH_RETURN(nullptr);
}
Z3_func_decl Z3_API Z3_mk_rec_func_decl(Z3_context c, Z3_symbol s, unsigned domain_size, Z3_sort const* domain,
Z3_sort range) {
Z3_TRY;
LOG_Z3_mk_rec_func_decl(c, s, domain_size, domain, range);
RESET_ERROR_CODE();
//
recfun::promise_def def =
mk_c(c)->recfun().get_plugin().mk_def(to_symbol(s),
domain_size,
to_sorts(domain),
to_sort(range));
func_decl* d = def.get_def()->get_decl();
mk_c(c)->save_ast_trail(d);
RETURN_Z3(of_func_decl(d));
Z3_CATCH_RETURN(nullptr);
}
void Z3_API Z3_add_rec_def(Z3_context c, Z3_func_decl f, unsigned n, Z3_ast args[], Z3_ast body) {
Z3_TRY;
LOG_Z3_add_rec_def(c, f, n, args, body);
func_decl* d = to_func_decl(f);
ast_manager& m = mk_c(c)->m();
recfun::decl::plugin& p = mk_c(c)->recfun().get_plugin();
expr_ref abs_body(m);
expr_ref_vector _args(m);
var_ref_vector _vars(m);
for (unsigned i = 0; i < n; ++i) {
_args.push_back(to_expr(args[i]));
_vars.push_back(m.mk_var(n - i - 1, m.get_sort(_args.back())));
if (m.get_sort(_args.back()) != d->get_domain(i)) {
SET_ERROR_CODE(Z3_INVALID_ARG, nullptr);
return;
}
}
expr_abstract(m, 0, n, _args.c_ptr(), to_expr(body), abs_body);
recfun::promise_def pd = p.get_promise_def(d);
if (!pd.get_def()) {
SET_ERROR_CODE(Z3_INVALID_ARG, nullptr);
return;
}
if (m.get_sort(abs_body) != d->get_range()) {
SET_ERROR_CODE(Z3_INVALID_ARG, nullptr);
return;
}
recfun_replace replace(m);
p.set_definition(replace, pd, n, _vars.c_ptr(), abs_body);
Z3_CATCH;
}
Z3_ast Z3_API Z3_mk_app(Z3_context c, Z3_func_decl d, unsigned num_args, Z3_ast const * args) {
Z3_TRY;
LOG_Z3_mk_app(c, d, num_args, args);
@ -256,12 +309,12 @@ extern "C" {
return to_sort(s)->get_id();
}
Z3_bool Z3_API Z3_is_well_sorted(Z3_context c, Z3_ast t) {
bool Z3_API Z3_is_well_sorted(Z3_context c, Z3_ast t) {
Z3_TRY;
LOG_Z3_is_well_sorted(c, t);
RESET_ERROR_CODE();
return is_well_sorted(mk_c(c)->m(), to_expr(t));
Z3_CATCH_RETURN(Z3_FALSE);
Z3_CATCH_RETURN(false);
}
Z3_symbol_kind Z3_API Z3_get_symbol_kind(Z3_context c, Z3_symbol s) {
@ -331,7 +384,7 @@ extern "C" {
return to_ast(a)->hash();
}
Z3_bool Z3_API Z3_is_app(Z3_context c, Z3_ast a) {
bool Z3_API Z3_is_app(Z3_context c, Z3_ast a) {
LOG_Z3_is_app(c, a);
RESET_ERROR_CODE();
return a != nullptr && is_app(reinterpret_cast<ast*>(a));
@ -468,7 +521,7 @@ extern "C" {
Z3_TRY;
LOG_Z3_get_decl_symbol_parameter(c, d, idx);
RESET_ERROR_CODE();
CHECK_VALID_AST(d, 0);
CHECK_VALID_AST(d, nullptr);
if (idx >= to_func_decl(d)->get_num_parameters()) {
SET_ERROR_CODE(Z3_IOB, nullptr);
return nullptr;
@ -486,7 +539,7 @@ extern "C" {
Z3_TRY;
LOG_Z3_get_decl_sort_parameter(c, d, idx);
RESET_ERROR_CODE();
CHECK_VALID_AST(d, 0);
CHECK_VALID_AST(d, nullptr);
if (idx >= to_func_decl(d)->get_num_parameters()) {
SET_ERROR_CODE(Z3_IOB, nullptr);
RETURN_Z3(nullptr);
@ -504,7 +557,7 @@ extern "C" {
Z3_TRY;
LOG_Z3_get_decl_ast_parameter(c, d, idx);
RESET_ERROR_CODE();
CHECK_VALID_AST(d, 0);
CHECK_VALID_AST(d, nullptr);
if (idx >= to_func_decl(d)->get_num_parameters()) {
SET_ERROR_CODE(Z3_IOB, nullptr);
RETURN_Z3(nullptr);
@ -522,7 +575,7 @@ extern "C" {
Z3_TRY;
LOG_Z3_get_decl_func_decl_parameter(c, d, idx);
RESET_ERROR_CODE();
CHECK_VALID_AST(d, 0);
CHECK_VALID_AST(d, nullptr);
if (idx >= to_func_decl(d)->get_num_parameters()) {
SET_ERROR_CODE(Z3_IOB, nullptr);
RETURN_Z3(nullptr);
@ -596,7 +649,7 @@ extern "C" {
Z3_TRY;
LOG_Z3_get_domain(c, d, i);
RESET_ERROR_CODE();
CHECK_VALID_AST(d, 0);
CHECK_VALID_AST(d, nullptr);
if (i >= to_func_decl(d)->get_arity()) {
SET_ERROR_CODE(Z3_IOB, nullptr);
RETURN_Z3(nullptr);
@ -681,6 +734,7 @@ extern "C" {
Z3_CATCH_RETURN(Z3_L_UNDEF);
}
static Z3_ast simplify(Z3_context c, Z3_ast _a, Z3_params _p) {
Z3_TRY;
RESET_ERROR_CODE();
@ -690,6 +744,7 @@ extern "C" {
unsigned timeout = p.get_uint("timeout", mk_c(c)->get_timeout());
bool use_ctrl_c = p.get_bool("ctrl_c", false);
th_rewriter m_rw(m, p);
m_rw.set_solver(alloc(api::seq_expr_solver, m, p));
expr_ref result(m);
cancel_eh<reslimit> eh(m.limit());
api::context::set_interruptable si(*(mk_c(c)), eh);

View file

@ -57,12 +57,12 @@ extern "C" {
Z3_CATCH;
}
Z3_bool Z3_API Z3_ast_map_contains(Z3_context c, Z3_ast_map m, Z3_ast k) {
bool Z3_API Z3_ast_map_contains(Z3_context c, Z3_ast_map m, Z3_ast k) {
Z3_TRY;
LOG_Z3_ast_map_contains(c, m, k);
RESET_ERROR_CODE();
return to_ast_map_ref(m).contains(to_ast(k));
Z3_CATCH_RETURN(Z3_FALSE);
Z3_CATCH_RETURN(false);
}
Z3_ast Z3_API Z3_ast_map_find(Z3_context c, Z3_ast_map m, Z3_ast k) {

View file

@ -106,7 +106,7 @@ Z3_ast Z3_API NAME(Z3_context c, unsigned i, Z3_ast n) { \
MK_BV_PUNARY(Z3_mk_rotate_right, OP_ROTATE_RIGHT);
MK_BV_PUNARY(Z3_mk_int2bv, OP_INT2BV);
Z3_ast Z3_API Z3_mk_bv2int(Z3_context c, Z3_ast n, Z3_bool is_signed) {
Z3_ast Z3_API Z3_mk_bv2int(Z3_context c, Z3_ast n, bool is_signed) {
Z3_TRY;
LOG_Z3_mk_bv2int(c, n, is_signed);
RESET_ERROR_CODE();
@ -186,7 +186,7 @@ Z3_ast Z3_API NAME(Z3_context c, unsigned i, Z3_ast n) { \
return Z3_mk_int(c, -1, s);
}
Z3_ast Z3_API Z3_mk_bvadd_no_overflow(Z3_context c, Z3_ast t1, Z3_ast t2, Z3_bool is_signed) {
Z3_ast Z3_API Z3_mk_bvadd_no_overflow(Z3_context c, Z3_ast t1, Z3_ast t2, bool is_signed) {
Z3_TRY;
RESET_ERROR_CODE();
if (is_signed) {
@ -286,7 +286,7 @@ Z3_ast Z3_API NAME(Z3_context c, unsigned i, Z3_ast n) { \
Z3_CATCH_RETURN(nullptr);
}
Z3_ast Z3_API Z3_mk_bvsub_no_underflow(Z3_context c, Z3_ast t1, Z3_ast t2, Z3_bool is_signed) {
Z3_ast Z3_API Z3_mk_bvsub_no_underflow(Z3_context c, Z3_ast t1, Z3_ast t2, bool is_signed) {
Z3_TRY;
RESET_ERROR_CODE();
if (is_signed) {
@ -311,7 +311,7 @@ Z3_ast Z3_API NAME(Z3_context c, unsigned i, Z3_ast n) { \
Z3_CATCH_RETURN(nullptr);
}
Z3_ast Z3_API Z3_mk_bvmul_no_overflow(Z3_context c, Z3_ast n1, Z3_ast n2, Z3_bool is_signed) {
Z3_ast Z3_API Z3_mk_bvmul_no_overflow(Z3_context c, Z3_ast n1, Z3_ast n2, bool is_signed) {
LOG_Z3_mk_bvmul_no_overflow(c, n1, n2, is_signed);
RESET_ERROR_CODE();
if (is_signed) {

View file

@ -57,21 +57,28 @@ extern "C" {
try {
g_Z3_global_param_get_buffer = gparams::get_value(param_id);
*param_value = g_Z3_global_param_get_buffer.c_str();
return Z3_TRUE;
return true;
}
catch (z3_exception & ex) {
// The error handler is only available for contexts
// Just throw a warning.
warning_msg("%s", ex.msg());
return Z3_FALSE;
return false;
}
}
Z3_config Z3_API Z3_mk_config(void) {
memory::initialize(UINT_MAX);
LOG_Z3_mk_config();
Z3_config r = reinterpret_cast<Z3_config>(alloc(context_params));
RETURN_Z3(r);
try {
memory::initialize(UINT_MAX);
LOG_Z3_mk_config();
Z3_config r = reinterpret_cast<Z3_config>(alloc(context_params));
RETURN_Z3(r);
} catch (z3_exception & ex) {
// The error handler is only available for contexts
// Just throw a warning.
warning_msg("%s", ex.msg());
return nullptr;
}
}
void Z3_API Z3_del_config(Z3_config c) {

View file

@ -19,7 +19,7 @@ Revision History:
--*/
#include<typeinfo>
#include "api/api_context.h"
#include "util/version.h"
#include "util/z3_version.h"
#include "ast/ast_pp.h"
#include "ast/ast_ll_pp.h"
#include "api/api_log_macros.h"
@ -79,6 +79,7 @@ namespace api {
m_datalog_util(m()),
m_fpa_util(m()),
m_sutil(m()),
m_recfun(m()),
m_last_result(m()),
m_ast_trail(m()),
m_pmanager(m_limit) {
@ -108,13 +109,10 @@ namespace api {
context::~context() {
m_last_obj = nullptr;
u_map<api::object*>::iterator it = m_allocated_objects.begin();
while (it != m_allocated_objects.end()) {
api::object* val = it->m_value;
DEBUG_CODE(warning_msg("Uncollected memory: %d: %s", it->m_key, typeid(*val).name()););
m_allocated_objects.remove(it->m_key);
for (auto& kv : m_allocated_objects) {
api::object* val = kv.m_value;
DEBUG_CODE(warning_msg("Uncollected memory: %d: %s", kv.m_key, typeid(*val).name()););
dealloc(val);
it = m_allocated_objects.begin();
}
}
@ -219,7 +217,7 @@ namespace api {
if (m_user_ref_count) {
// Corner case bug: n may be in m_last_result, and this is the only reference to n.
// When, we execute reset() it is deleted
// To avoid this bug, I bump the reference counter before reseting m_last_result
// To avoid this bug, I bump the reference counter before resetting m_last_result
ast_ref node(n, m());
m_last_result.reset();
m_last_result.push_back(std::move(node));
@ -362,7 +360,7 @@ extern "C" {
Z3_CATCH;
}
void Z3_API Z3_toggle_warning_messages(Z3_bool enabled) {
void Z3_API Z3_toggle_warning_messages(bool enabled) {
LOG_Z3_toggle_warning_messages(enabled);
enable_warning_messages(enabled != 0);
}
@ -439,7 +437,6 @@ extern "C" {
void Z3_API Z3_set_error_handler(Z3_context c, Z3_error_handler h) {
RESET_ERROR_CODE();
mk_c(c)->set_error_handler(h);
// [Leo]: using exception handling, we don't need global error handlers anymore
}
void Z3_API Z3_set_error(Z3_context c, Z3_error_code e) {
@ -489,9 +486,3 @@ extern "C" {
}
};
Z3_API ast_manager& Z3_get_manager(Z3_context c) {
return mk_c(c)->m();
}

View file

@ -29,6 +29,7 @@ Revision History:
#include "ast/datatype_decl_plugin.h"
#include "ast/dl_decl_plugin.h"
#include "ast/fpa_decl_plugin.h"
#include "ast/recfun_decl_plugin.h"
#include "smt/smt_kernel.h"
#include "smt/params/smt_params.h"
#include "util/event_handler.h"
@ -37,6 +38,9 @@ Revision History:
#include "cmd_context/cmd_context.h"
#include "api/api_polynomial.h"
#include "util/hashtable.h"
#include "ast/rewriter/seq_rewriter.h"
#include "smt/smt_solver.h"
#include "solver/solver.h"
namespace smtlib {
class parser;
@ -48,6 +52,24 @@ namespace realclosure {
namespace api {
class seq_expr_solver : public expr_solver {
ast_manager& m;
params_ref const& p;
solver_ref s;
public:
seq_expr_solver(ast_manager& m, params_ref const& p): m(m), p(p) {}
lbool check_sat(expr* e) {
if (!s) {
s = mk_smt_solver(m, p, symbol("ALL"));
}
s->push();
s->assert_expr(e);
lbool r = s->check_sat();
s->pop(1);
return r;
}
};
class context : public tactic_manager {
struct add_plugins { add_plugins(ast_manager & m); };
@ -62,6 +84,7 @@ namespace api {
datalog::dl_decl_util m_datalog_util;
fpa_util m_fpa_util;
seq_util m_sutil;
recfun::util m_recfun;
// Support for old solver API
smt_params m_fparams;
@ -128,6 +151,7 @@ namespace api {
fpa_util & fpautil() { return m_fpa_util; }
datatype_util& dtutil() { return m_dt_plugin->u(); }
seq_util& sutil() { return m_sutil; }
recfun::util& recfun() { return m_recfun; }
family_id get_basic_fid() const { return m_basic_fid; }
family_id get_array_fid() const { return m_array_fid; }
family_id get_arith_fid() const { return m_arith_fid; }

View file

@ -199,23 +199,23 @@ extern "C" {
Z3_CATCH_RETURN(nullptr);
}
Z3_bool Z3_API Z3_get_finite_domain_sort_size(Z3_context c, Z3_sort s, uint64_t * out) {
bool Z3_API Z3_get_finite_domain_sort_size(Z3_context c, Z3_sort s, uint64_t * out) {
Z3_TRY;
if (out) {
*out = 0;
}
if (Z3_get_sort_kind(c, s) != Z3_FINITE_DOMAIN_SORT) {
return Z3_FALSE;
return false;
}
if (!out) {
return Z3_FALSE;
return false;
}
// must start loggging here, since function uses Z3_get_sort_kind above
// must start logging here, since function uses Z3_get_sort_kind above
LOG_Z3_get_finite_domain_sort_size(c, s, out);
RESET_ERROR_CODE();
VERIFY(mk_c(c)->datalog_util().try_get_size(to_sort(s), *out));
return Z3_TRUE;
Z3_CATCH_RETURN(Z3_FALSE);
return true;
Z3_CATCH_RETURN(false);
}
Z3_fixedpoint Z3_API Z3_mk_fixedpoint(Z3_context c) {
@ -379,10 +379,8 @@ extern "C" {
for (unsigned i = 0; i < coll.m_rules.size(); ++i) {
to_fixedpoint_ref(d)->add_rule(coll.m_rules[i].get(), coll.m_names[i]);
}
ptr_vector<expr>::const_iterator it = ctx.begin_assertions();
ptr_vector<expr>::const_iterator end = ctx.end_assertions();
for (; it != end; ++it) {
to_fixedpoint_ref(d)->ctx().assert_expr(*it);
for (expr * e : ctx.assertions()) {
to_fixedpoint_ref(d)->ctx().assert_expr(e);
}
return of_ast_vector(v);
@ -717,6 +715,4 @@ extern "C" {
Z3_CATCH_RETURN(nullptr);
}
};

View file

@ -232,7 +232,7 @@ extern "C" {
Z3_CATCH_RETURN(nullptr);
}
Z3_ast Z3_API Z3_mk_fpa_inf(Z3_context c, Z3_sort s, Z3_bool negative) {
Z3_ast Z3_API Z3_mk_fpa_inf(Z3_context c, Z3_sort s, bool negative) {
Z3_TRY;
LOG_Z3_mk_fpa_inf(c, s, negative);
RESET_ERROR_CODE();
@ -242,14 +242,14 @@ extern "C" {
RETURN_Z3(nullptr);
}
api::context * ctx = mk_c(c);
expr * a = negative != 0 ? ctx->fpautil().mk_ninf(to_sort(s)) :
ctx->fpautil().mk_pinf(to_sort(s));
expr * a = negative ? ctx->fpautil().mk_ninf(to_sort(s)) :
ctx->fpautil().mk_pinf(to_sort(s));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(nullptr);
}
Z3_ast Z3_API Z3_mk_fpa_zero(Z3_context c, Z3_sort s, Z3_bool negative) {
Z3_ast Z3_API Z3_mk_fpa_zero(Z3_context c, Z3_sort s, bool negative) {
Z3_TRY;
LOG_Z3_mk_fpa_inf(c, s, negative);
RESET_ERROR_CODE();
@ -259,8 +259,8 @@ extern "C" {
RETURN_Z3(nullptr);
}
api::context * ctx = mk_c(c);
expr * a = negative != 0 ? ctx->fpautil().mk_nzero(to_sort(s)) :
ctx->fpautil().mk_pzero(to_sort(s));
expr * a = negative ? ctx->fpautil().mk_nzero(to_sort(s)) :
ctx->fpautil().mk_pzero(to_sort(s));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(nullptr);
@ -338,7 +338,7 @@ extern "C" {
Z3_CATCH_RETURN(nullptr);
}
Z3_ast Z3_API Z3_mk_fpa_numeral_int_uint(Z3_context c, Z3_bool sgn, signed exp, unsigned sig, Z3_sort ty) {
Z3_ast Z3_API Z3_mk_fpa_numeral_int_uint(Z3_context c, bool sgn, signed exp, unsigned sig, Z3_sort ty) {
Z3_TRY;
LOG_Z3_mk_fpa_numeral_int64_uint64(c, sgn, exp, sig, ty);
RESET_ERROR_CODE();
@ -351,14 +351,14 @@ extern "C" {
ctx->fpautil().fm().set(tmp,
ctx->fpautil().get_ebits(to_sort(ty)),
ctx->fpautil().get_sbits(to_sort(ty)),
sgn != 0, exp, sig);
sgn, exp, sig);
expr * a = ctx->fpautil().mk_value(tmp);
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(nullptr);
}
Z3_ast Z3_API Z3_mk_fpa_numeral_int64_uint64(Z3_context c, Z3_bool sgn, int64_t exp, uint64_t sig, Z3_sort ty) {
Z3_ast Z3_API Z3_mk_fpa_numeral_int64_uint64(Z3_context c, bool sgn, int64_t exp, uint64_t sig, Z3_sort ty) {
Z3_TRY;
LOG_Z3_mk_fpa_numeral_int64_uint64(c, sgn, exp, sig, ty);
RESET_ERROR_CODE();
@ -371,7 +371,7 @@ extern "C" {
ctx->fpautil().fm().set(tmp,
ctx->fpautil().get_ebits(to_sort(ty)),
ctx->fpautil().get_sbits(to_sort(ty)),
sgn != 0, exp, sig);
sgn, exp, sig);
expr * a = ctx->fpautil().mk_value(tmp);
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
@ -905,7 +905,7 @@ extern "C" {
Z3_CATCH_RETURN(0);
}
Z3_bool Z3_API Z3_fpa_get_numeral_sign(Z3_context c, Z3_ast t, int * sgn) {
bool Z3_API Z3_fpa_get_numeral_sign(Z3_context c, Z3_ast t, int * sgn) {
Z3_TRY;
LOG_Z3_fpa_get_numeral_sign(c, t, sgn);
RESET_ERROR_CODE();
@ -913,7 +913,7 @@ extern "C" {
CHECK_VALID_AST(t, 0);
if (sgn == nullptr) {
SET_ERROR_CODE(Z3_INVALID_ARG, "sign cannot be a nullpointer");
return 0;
return false;
}
ast_manager & m = mk_c(c)->m();
mpf_manager & mpfm = mk_c(c)->fpautil().fm();
@ -922,13 +922,13 @@ extern "C" {
expr * e = to_expr(t);
if (!is_app(e) || is_app_of(e, fid, OP_FPA_NAN) || !is_fp(c, t)) {
SET_ERROR_CODE(Z3_INVALID_ARG, "invalid expression argument, expecting a valid fp, not a NaN");
return 0;
return false;
}
scoped_mpf val(mpfm);
bool r = plugin->is_numeral(to_expr(t), val);
if (!r || mpfm.is_nan(val)) {
SET_ERROR_CODE(Z3_INVALID_ARG, "invalid expression argument, expecting a valid fp, not a NaN");
return 0;
return false;
}
*sgn = mpfm.sgn(val);
return r;
@ -1035,7 +1035,7 @@ extern "C" {
Z3_CATCH_RETURN("");
}
Z3_bool Z3_API Z3_fpa_get_numeral_significand_uint64(Z3_context c, Z3_ast t, uint64_t * n) {
bool Z3_API Z3_fpa_get_numeral_significand_uint64(Z3_context c, Z3_ast t, uint64_t * n) {
Z3_TRY;
LOG_Z3_fpa_get_numeral_significand_uint64(c, t, n);
RESET_ERROR_CODE();
@ -1043,7 +1043,7 @@ extern "C" {
CHECK_VALID_AST(t, 0);
if (n == nullptr) {
SET_ERROR_CODE(Z3_INVALID_ARG, "invalid nullptr argument");
return 0;
return false;
}
ast_manager & m = mk_c(c)->m();
mpf_manager & mpfm = mk_c(c)->fpautil().fm();
@ -1055,7 +1055,7 @@ extern "C" {
if (!is_app(e) || is_app_of(e, fid, OP_FPA_NAN) || !is_fp(c, t)) {
SET_ERROR_CODE(Z3_INVALID_ARG, "invalid expression argument, expecting a valid fp, not a NaN");
*n = 0;
return 0;
return false;
}
scoped_mpf val(mpfm);
bool r = plugin->is_numeral(e, val);
@ -1065,14 +1065,14 @@ extern "C" {
!mpzm.is_uint64(z)) {
SET_ERROR_CODE(Z3_INVALID_ARG, "invalid expression argument, expecting a valid fp, not a NaN");
*n = 0;
return 0;
return false;
}
*n = mpzm.get_uint64(z);
return 1;
return true;
Z3_CATCH_RETURN(0);
}
Z3_string Z3_API Z3_fpa_get_numeral_exponent_string(Z3_context c, Z3_ast t, Z3_bool biased) {
Z3_string Z3_API Z3_fpa_get_numeral_exponent_string(Z3_context c, Z3_ast t, bool biased) {
Z3_TRY;
LOG_Z3_fpa_get_numeral_exponent_string(c, t, biased);
RESET_ERROR_CODE();
@ -1113,7 +1113,7 @@ extern "C" {
Z3_CATCH_RETURN("");
}
Z3_bool Z3_API Z3_fpa_get_numeral_exponent_int64(Z3_context c, Z3_ast t, int64_t * n, Z3_bool biased) {
bool Z3_API Z3_fpa_get_numeral_exponent_int64(Z3_context c, Z3_ast t, int64_t * n, bool biased) {
Z3_TRY;
LOG_Z3_fpa_get_numeral_exponent_int64(c, t, n, biased);
RESET_ERROR_CODE();
@ -1121,7 +1121,7 @@ extern "C" {
CHECK_VALID_AST(t, 0);
if (n == nullptr) {
SET_ERROR_CODE(Z3_INVALID_ARG, "invalid null argument");
return 0;
return false;
}
ast_manager & m = mk_c(c)->m();
mpf_manager & mpfm = mk_c(c)->fpautil().fm();
@ -1132,14 +1132,14 @@ extern "C" {
if (!is_app(e) || is_app_of(e, fid, OP_FPA_NAN) || !is_fp(c, t)) {
SET_ERROR_CODE(Z3_INVALID_ARG, "invalid expression argument, expecting a valid fp, not a NaN");
*n = 0;
return 0;
return false;
}
scoped_mpf val(mpfm);
bool r = plugin->is_numeral(e, val);
if (!r || !(mpfm.is_normal(val) || mpfm.is_denormal(val) || mpfm.is_zero(val) || mpfm.is_inf(val))) {
SET_ERROR_CODE(Z3_INVALID_ARG, "invalid expression argument, expecting a valid fp, not a NaN");
*n = 0;
return 0;
return false;
}
unsigned ebits = val.get().get_ebits();
if (biased) {
@ -1153,11 +1153,11 @@ extern "C" {
mpfm.is_denormal(val) ? mpfm.mk_min_exp(ebits) :
mpfm.exp(val);
}
return 1;
return true;
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_fpa_get_numeral_exponent_bv(Z3_context c, Z3_ast t, Z3_bool biased) {
Z3_ast Z3_API Z3_fpa_get_numeral_exponent_bv(Z3_context c, Z3_ast t, bool biased) {
Z3_TRY;
LOG_Z3_fpa_get_numeral_exponent_bv(c, t, biased);
RESET_ERROR_CODE();
@ -1232,7 +1232,7 @@ extern "C" {
Z3_CATCH_RETURN(nullptr);
}
Z3_bool Z3_API Z3_fpa_is_numeral_nan(Z3_context c, Z3_ast t) {
bool Z3_API Z3_fpa_is_numeral_nan(Z3_context c, Z3_ast t) {
Z3_TRY;
LOG_Z3_fpa_is_numeral_nan(c, t);
RESET_ERROR_CODE();
@ -1240,13 +1240,13 @@ extern "C" {
fpa_util & fu = ctx->fpautil();
if (!is_expr(t) || !fu.is_numeral(to_expr(t))) {
SET_ERROR_CODE(Z3_INVALID_ARG, nullptr);
return 0;
return false;
}
return fu.is_nan(to_expr(t));
Z3_CATCH_RETURN(Z3_FALSE);
Z3_CATCH_RETURN(false);
}
Z3_bool Z3_API Z3_fpa_is_numeral_inf(Z3_context c, Z3_ast t) {
bool Z3_API Z3_fpa_is_numeral_inf(Z3_context c, Z3_ast t) {
Z3_TRY;
LOG_Z3_fpa_is_numeral_inf(c, t);
RESET_ERROR_CODE();
@ -1254,13 +1254,13 @@ extern "C" {
fpa_util & fu = ctx->fpautil();
if (!is_expr(t) || !fu.is_numeral(to_expr(t))) {
SET_ERROR_CODE(Z3_INVALID_ARG, nullptr);
return 0;
return false;
}
return fu.is_inf(to_expr(t));
Z3_CATCH_RETURN(Z3_FALSE);
Z3_CATCH_RETURN(false);
}
Z3_bool Z3_API Z3_fpa_is_numeral_zero(Z3_context c, Z3_ast t) {
bool Z3_API Z3_fpa_is_numeral_zero(Z3_context c, Z3_ast t) {
Z3_TRY;
LOG_Z3_fpa_is_numeral_zero(c, t);
RESET_ERROR_CODE();
@ -1268,13 +1268,13 @@ extern "C" {
fpa_util & fu = ctx->fpautil();
if (!is_expr(t) || !fu.is_numeral(to_expr(t))) {
SET_ERROR_CODE(Z3_INVALID_ARG, nullptr);
return 0;
return false;
}
return fu.is_zero(to_expr(t));
Z3_CATCH_RETURN(Z3_FALSE);
Z3_CATCH_RETURN(false);
}
Z3_bool Z3_API Z3_fpa_is_numeral_normal(Z3_context c, Z3_ast t) {
bool Z3_API Z3_fpa_is_numeral_normal(Z3_context c, Z3_ast t) {
Z3_TRY;
LOG_Z3_fpa_is_numeral_normal(c, t);
RESET_ERROR_CODE();
@ -1282,13 +1282,13 @@ extern "C" {
fpa_util & fu = ctx->fpautil();
if (!is_expr(t) || !fu.is_numeral(to_expr(t))) {
SET_ERROR_CODE(Z3_INVALID_ARG, nullptr);
return 0;
return false;
}
return fu.is_normal(to_expr(t));
Z3_CATCH_RETURN(Z3_FALSE);
Z3_CATCH_RETURN(false);
}
Z3_bool Z3_API Z3_fpa_is_numeral_subnormal(Z3_context c, Z3_ast t) {
bool Z3_API Z3_fpa_is_numeral_subnormal(Z3_context c, Z3_ast t) {
Z3_TRY;
LOG_Z3_fpa_is_numeral_subnormal(c, t);
RESET_ERROR_CODE();
@ -1296,13 +1296,13 @@ extern "C" {
fpa_util & fu = ctx->fpautil();
if (!is_expr(t) || !fu.is_numeral(to_expr(t))) {
SET_ERROR_CODE(Z3_INVALID_ARG, nullptr);
return 0;
return false;
}
return fu.is_subnormal(to_expr(t));
Z3_CATCH_RETURN(Z3_FALSE);
Z3_CATCH_RETURN(false);
}
Z3_bool Z3_API Z3_fpa_is_numeral_positive(Z3_context c, Z3_ast t) {
bool Z3_API Z3_fpa_is_numeral_positive(Z3_context c, Z3_ast t) {
Z3_TRY;
LOG_Z3_fpa_is_numeral_positive(c, t);
RESET_ERROR_CODE();
@ -1310,13 +1310,13 @@ extern "C" {
fpa_util & fu = ctx->fpautil();
if (!is_expr(t) || !fu.is_numeral(to_expr(t))) {
SET_ERROR_CODE(Z3_INVALID_ARG, nullptr);
return 0;
return false;
}
return fu.is_positive(to_expr(t));
Z3_CATCH_RETURN(Z3_FALSE);
Z3_CATCH_RETURN(false);
}
Z3_bool Z3_API Z3_fpa_is_numeral_negative(Z3_context c, Z3_ast t) {
bool Z3_API Z3_fpa_is_numeral_negative(Z3_context c, Z3_ast t) {
Z3_TRY;
LOG_Z3_fpa_is_numeral_negative(c, t);
RESET_ERROR_CODE();
@ -1324,10 +1324,10 @@ extern "C" {
fpa_util & fu = ctx->fpautil();
if (!is_expr(t) || !fu.is_numeral(to_expr(t))) {
SET_ERROR_CODE(Z3_INVALID_ARG, nullptr);
return 0;
return false;
}
return fu.is_negative(to_expr(t));
Z3_CATCH_RETURN(Z3_FALSE);
Z3_CATCH_RETURN(false);
}
};

View file

@ -25,7 +25,7 @@ Revision History:
extern "C" {
Z3_goal Z3_API Z3_mk_goal(Z3_context c, Z3_bool models, Z3_bool unsat_cores, Z3_bool proofs) {
Z3_goal Z3_API Z3_mk_goal(Z3_context c, bool models, bool unsat_cores, bool proofs) {
Z3_TRY;
LOG_Z3_mk_goal(c, models, unsat_cores, proofs);
RESET_ERROR_CODE();
@ -82,12 +82,12 @@ extern "C" {
Z3_CATCH;
}
Z3_bool Z3_API Z3_goal_inconsistent(Z3_context c, Z3_goal g) {
bool Z3_API Z3_goal_inconsistent(Z3_context c, Z3_goal g) {
Z3_TRY;
LOG_Z3_goal_inconsistent(c, g);
RESET_ERROR_CODE();
return to_goal_ref(g)->inconsistent();
Z3_CATCH_RETURN(Z3_FALSE);
Z3_CATCH_RETURN(false);
}
unsigned Z3_API Z3_goal_depth(Z3_context c, Z3_goal g) {
@ -136,20 +136,20 @@ extern "C" {
Z3_CATCH_RETURN(0);
}
Z3_bool Z3_API Z3_goal_is_decided_sat(Z3_context c, Z3_goal g) {
bool Z3_API Z3_goal_is_decided_sat(Z3_context c, Z3_goal g) {
Z3_TRY;
LOG_Z3_goal_is_decided_sat(c, g);
RESET_ERROR_CODE();
return to_goal_ref(g)->is_decided_sat();
Z3_CATCH_RETURN(Z3_FALSE);
Z3_CATCH_RETURN(false);
}
Z3_bool Z3_API Z3_goal_is_decided_unsat(Z3_context c, Z3_goal g) {
bool Z3_API Z3_goal_is_decided_unsat(Z3_context c, Z3_goal g) {
Z3_TRY;
LOG_Z3_goal_is_decided_unsat(c, g);
RESET_ERROR_CODE();
return to_goal_ref(g)->is_decided_unsat();
Z3_CATCH_RETURN(Z3_FALSE);
Z3_CATCH_RETURN(false);
}
Z3_model Z3_API Z3_goal_convert_model(Z3_context c, Z3_goal g, Z3_model m) {
@ -163,7 +163,7 @@ extern "C" {
if (to_goal_ref(g)->mc())
(*to_goal_ref(g)->mc())(m_ref->m_model);
RETURN_Z3(of_model(m_ref));
Z3_CATCH_RETURN(0);
Z3_CATCH_RETURN(nullptr);
}
Z3_goal Z3_API Z3_goal_translate(Z3_context c, Z3_goal g, Z3_context target) {

View file

@ -19,7 +19,7 @@ Revision History:
#include "api/z3.h"
#include "api/api_log_macros.h"
#include "util/util.h"
#include "util/version.h"
#include "util/z3_version.h"
std::ostream * g_z3_log = nullptr;
bool g_z3_log_enabled = false;
@ -33,8 +33,8 @@ extern "C" {
}
}
Z3_bool Z3_API Z3_open_log(Z3_string filename) {
Z3_bool res = Z3_TRUE;
bool Z3_API Z3_open_log(Z3_string filename) {
bool res = true;
#ifdef Z3_LOG_SYNC
#pragma omp critical (z3_log)
@ -46,7 +46,7 @@ extern "C" {
if (g_z3_log->bad() || g_z3_log->fail()) {
dealloc(g_z3_log);
g_z3_log = nullptr;
res = Z3_FALSE;
res = false;
}
else {
*g_z3_log << "V \"" << Z3_MAJOR_VERSION << "." << Z3_MINOR_VERSION << "." << Z3_BUILD_NUMBER << "." << Z3_REVISION_NUMBER << " " << __DATE__ << "\"\n";

View file

@ -75,16 +75,12 @@ extern "C" {
Z3_CATCH_RETURN(nullptr);
}
Z3_bool Z3_API Z3_model_has_interp(Z3_context c, Z3_model m, Z3_func_decl a) {
bool Z3_API Z3_model_has_interp(Z3_context c, Z3_model m, Z3_func_decl a) {
Z3_TRY;
LOG_Z3_model_has_interp(c, m, a);
CHECK_NON_NULL(m, 0);
if (to_model_ref(m)->has_interpretation(to_func_decl(a))) {
return Z3_TRUE;
} else {
return Z3_FALSE;
}
Z3_CATCH_RETURN(Z3_FALSE);
return to_model_ref(m)->has_interpretation(to_func_decl(a));
Z3_CATCH_RETURN(false);
}
Z3_func_interp Z3_API Z3_model_get_func_interp(Z3_context c, Z3_model m, Z3_func_decl f) {
@ -157,20 +153,23 @@ extern "C" {
Z3_CATCH_RETURN(nullptr);
}
Z3_bool Z3_API Z3_model_eval(Z3_context c, Z3_model m, Z3_ast t, Z3_bool model_completion, Z3_ast * v) {
bool Z3_API Z3_model_eval(Z3_context c, Z3_model m, Z3_ast t, bool model_completion, Z3_ast * v) {
Z3_TRY;
LOG_Z3_model_eval(c, m, t, model_completion, v);
if (v) *v = nullptr;
RESET_ERROR_CODE();
CHECK_NON_NULL(m, Z3_FALSE);
CHECK_IS_EXPR(t, Z3_FALSE);
CHECK_NON_NULL(m, false);
CHECK_IS_EXPR(t, false);
model * _m = to_model_ref(m);
expr_ref result(mk_c(c)->m());
model::scoped_model_completion _scm(*_m, model_completion == Z3_TRUE);
params_ref p;
ast_manager& mgr = mk_c(c)->m();
_m->set_solver(alloc(api::seq_expr_solver, mgr, p));
expr_ref result(mgr);
model::scoped_model_completion _scm(*_m, model_completion);
result = (*_m)(to_expr(t));
mk_c(c)->save_ast_trail(result.get());
*v = of_ast(result.get());
RETURN_Z3_model_eval Z3_TRUE;
RETURN_Z3_model_eval true;
Z3_CATCH_RETURN(0);
}
@ -225,12 +224,12 @@ extern "C" {
Z3_CATCH_RETURN(nullptr);
}
Z3_bool Z3_API Z3_is_as_array(Z3_context c, Z3_ast a) {
bool Z3_API Z3_is_as_array(Z3_context c, Z3_ast a) {
Z3_TRY;
LOG_Z3_is_as_array(c, a);
RESET_ERROR_CODE();
return a && is_expr(to_ast(a)) && is_app_of(to_expr(a), mk_c(c)->get_array_fid(), OP_AS_ARRAY);
Z3_CATCH_RETURN(Z3_FALSE);
Z3_CATCH_RETURN(false);
}
Z3_func_decl Z3_API Z3_get_as_array_func_decl(Z3_context c, Z3_ast a) {
@ -472,7 +471,7 @@ extern "C" {
model_smt2_pp(buffer, mk_c(c)->m(), *(to_model_ref(m)), 0);
// Hack for removing the trailing '\n'
result = buffer.str();
if (result.size() != 0)
if (!result.empty())
result.resize(result.size()-1);
}
else {

View file

@ -142,11 +142,11 @@ extern "C" {
Z3_CATCH_RETURN(nullptr);
}
Z3_bool Z3_API Z3_is_numeral_ast(Z3_context c, Z3_ast a) {
bool Z3_API Z3_is_numeral_ast(Z3_context c, Z3_ast a) {
Z3_TRY;
LOG_Z3_is_numeral_ast(c, a);
RESET_ERROR_CODE();
CHECK_IS_EXPR(a, Z3_FALSE);
CHECK_IS_EXPR(a, false);
expr* e = to_expr(a);
return
mk_c(c)->autil().is_numeral(e) ||
@ -154,29 +154,29 @@ extern "C" {
mk_c(c)->fpautil().is_numeral(e) ||
mk_c(c)->fpautil().is_rm_numeral(e) ||
mk_c(c)->datalog_util().is_numeral_ext(e);
Z3_CATCH_RETURN(Z3_FALSE);
Z3_CATCH_RETURN(false);
}
Z3_bool Z3_API Z3_get_numeral_rational(Z3_context c, Z3_ast a, rational& r) {
bool Z3_API Z3_get_numeral_rational(Z3_context c, Z3_ast a, rational& r) {
Z3_TRY;
// This function is not part of the public API
RESET_ERROR_CODE();
CHECK_IS_EXPR(a, Z3_FALSE);
CHECK_IS_EXPR(a, false);
expr* e = to_expr(a);
if (mk_c(c)->autil().is_numeral(e, r)) {
return Z3_TRUE;
return true;
}
unsigned bv_size;
if (mk_c(c)->bvutil().is_numeral(e, r, bv_size)) {
return Z3_TRUE;
return true;
}
uint64_t v;
if (mk_c(c)->datalog_util().is_numeral(e, v)) {
r = rational(v, rational::ui64());
return Z3_TRUE;
return true;
}
return Z3_FALSE;
Z3_CATCH_RETURN(Z3_FALSE);
return false;
Z3_CATCH_RETURN(false);
}
@ -187,8 +187,8 @@ extern "C" {
RESET_ERROR_CODE();
CHECK_IS_EXPR(a, "");
rational r;
Z3_bool ok = Z3_get_numeral_rational(c, a, r);
if (ok == Z3_TRUE) {
bool ok = Z3_get_numeral_rational(c, a, r);
if (ok) {
return mk_c(c)->mk_external_string(r.to_string());
}
else {
@ -198,19 +198,19 @@ extern "C" {
mpf_rounding_mode rm;
if (mk_c(c)->fpautil().is_rm_numeral(to_expr(a), rm)) {
switch (rm) {
case OP_FPA_RM_NEAREST_TIES_TO_EVEN:
case MPF_ROUND_NEAREST_TEVEN:
return mk_c(c)->mk_external_string("roundNearestTiesToEven");
break;
case OP_FPA_RM_NEAREST_TIES_TO_AWAY:
case MPF_ROUND_NEAREST_TAWAY:
return mk_c(c)->mk_external_string("roundNearestTiesToAway");
break;
case OP_FPA_RM_TOWARD_POSITIVE:
case MPF_ROUND_TOWARD_POSITIVE:
return mk_c(c)->mk_external_string("roundTowardPositive");
break;
case OP_FPA_RM_TOWARD_NEGATIVE:
case MPF_ROUND_TOWARD_NEGATIVE:
return mk_c(c)->mk_external_string("roundTowardNegative");
break;
case OP_FPA_RM_TOWARD_ZERO:
case MPF_ROUND_TOWARD_ZERO:
default:
return mk_c(c)->mk_external_string("roundTowardZero");
break;
@ -227,6 +227,11 @@ extern "C" {
Z3_CATCH_RETURN("");
}
double Z3_API Z3_get_numeral_double(Z3_context c, Z3_ast a) {
Z3_string s = Z3_get_numeral_decimal_string(c, a, 12);
return std::stod(std::string(s));
}
Z3_string Z3_API Z3_get_numeral_decimal_string(Z3_context c, Z3_ast a, unsigned precision) {
Z3_TRY;
LOG_Z3_get_numeral_decimal_string(c, a, precision);
@ -247,8 +252,8 @@ extern "C" {
am.display_decimal(buffer, n, precision);
return mk_c(c)->mk_external_string(buffer.str());
}
Z3_bool ok = Z3_get_numeral_rational(c, a, r);
if (ok == Z3_TRUE) {
bool ok = Z3_get_numeral_rational(c, a, r);
if (ok) {
return mk_c(c)->mk_external_string(r.to_string());
}
else {
@ -258,124 +263,124 @@ extern "C" {
Z3_CATCH_RETURN("");
}
Z3_bool Z3_API Z3_get_numeral_small(Z3_context c, Z3_ast a, int64_t* num, int64_t* den) {
bool Z3_API Z3_get_numeral_small(Z3_context c, Z3_ast a, int64_t* num, int64_t* den) {
Z3_TRY;
// This function invokes Z3_get_numeral_rational, but it is still ok to add LOG command here because it does not return a Z3 object.
LOG_Z3_get_numeral_small(c, a, num, den);
RESET_ERROR_CODE();
CHECK_IS_EXPR(a, Z3_FALSE);
CHECK_IS_EXPR(a, false);
rational r;
Z3_bool ok = Z3_get_numeral_rational(c, a, r);
if (ok == Z3_TRUE) {
bool ok = Z3_get_numeral_rational(c, a, r);
if (ok) {
rational n = numerator(r);
rational d = denominator(r);
if (n.is_int64() && d.is_int64()) {
*num = n.get_int64();
*den = d.get_int64();
return Z3_TRUE;
return true;
}
else {
return Z3_FALSE;
return false;
}
}
SET_ERROR_CODE(Z3_INVALID_ARG, nullptr);
return Z3_FALSE;
Z3_CATCH_RETURN(Z3_FALSE);
return false;
Z3_CATCH_RETURN(false);
}
Z3_bool Z3_API Z3_get_numeral_int(Z3_context c, Z3_ast v, int* i) {
bool Z3_API Z3_get_numeral_int(Z3_context c, Z3_ast v, int* i) {
Z3_TRY;
// This function invokes Z3_get_numeral_int64, but it is still ok to add LOG command here because it does not return a Z3 object.
LOG_Z3_get_numeral_int(c, v, i);
RESET_ERROR_CODE();
CHECK_IS_EXPR(v, Z3_FALSE);
CHECK_IS_EXPR(v, false);
if (!i) {
SET_ERROR_CODE(Z3_INVALID_ARG, nullptr);
return Z3_FALSE;
return false;
}
int64_t l;
if (Z3_get_numeral_int64(c, v, &l) && l >= INT_MIN && l <= INT_MAX) {
*i = static_cast<int>(l);
return Z3_TRUE;
return true;
}
return Z3_FALSE;
Z3_CATCH_RETURN(Z3_FALSE);
return false;
Z3_CATCH_RETURN(false);
}
Z3_bool Z3_API Z3_get_numeral_uint(Z3_context c, Z3_ast v, unsigned* u) {
bool Z3_API Z3_get_numeral_uint(Z3_context c, Z3_ast v, unsigned* u) {
Z3_TRY;
// This function invokes Z3_get_numeral_uint64, but it is still ok to add LOG command here because it does not return a Z3 object.
LOG_Z3_get_numeral_uint(c, v, u);
RESET_ERROR_CODE();
CHECK_IS_EXPR(v, Z3_FALSE);
CHECK_IS_EXPR(v, false);
if (!u) {
SET_ERROR_CODE(Z3_INVALID_ARG, nullptr);
return Z3_FALSE;
return false;
}
uint64_t l;
if (Z3_get_numeral_uint64(c, v, &l) && (l <= 0xFFFFFFFF)) {
*u = static_cast<unsigned>(l);
return Z3_TRUE;
return true;
}
return Z3_FALSE;
Z3_CATCH_RETURN(Z3_FALSE);
return false;
Z3_CATCH_RETURN(false);
}
Z3_bool Z3_API Z3_get_numeral_uint64(Z3_context c, Z3_ast v, uint64_t* u) {
bool Z3_API Z3_get_numeral_uint64(Z3_context c, Z3_ast v, uint64_t* u) {
Z3_TRY;
// This function invokes Z3_get_numeral_rational, but it is still ok to add LOG command here because it does not return a Z3 object.
LOG_Z3_get_numeral_uint64(c, v, u);
RESET_ERROR_CODE();
CHECK_IS_EXPR(v, Z3_FALSE);
CHECK_IS_EXPR(v, false);
if (!u) {
SET_ERROR_CODE(Z3_INVALID_ARG, nullptr);
return Z3_FALSE;
return false;
}
rational r;
Z3_bool ok = Z3_get_numeral_rational(c, v, r);
bool ok = Z3_get_numeral_rational(c, v, r);
SASSERT(u);
if (ok == Z3_TRUE && r.is_uint64()) {
if (ok && r.is_uint64()) {
*u = r.get_uint64();
return ok;
}
return Z3_FALSE;
Z3_CATCH_RETURN(Z3_FALSE);
return false;
Z3_CATCH_RETURN(false);
}
Z3_bool Z3_API Z3_get_numeral_int64(Z3_context c, Z3_ast v, int64_t* i) {
bool Z3_API Z3_get_numeral_int64(Z3_context c, Z3_ast v, int64_t* i) {
Z3_TRY;
// This function invokes Z3_get_numeral_rational, but it is still ok to add LOG command here because it does not return a Z3 object.
LOG_Z3_get_numeral_int64(c, v, i);
RESET_ERROR_CODE();
CHECK_IS_EXPR(v, Z3_FALSE);
CHECK_IS_EXPR(v, false);
if (!i) {
SET_ERROR_CODE(Z3_INVALID_ARG, nullptr);
return Z3_FALSE;
return false;
}
rational r;
Z3_bool ok = Z3_get_numeral_rational(c, v, r);
if (ok == Z3_TRUE && r.is_int64()) {
bool ok = Z3_get_numeral_rational(c, v, r);
if (ok && r.is_int64()) {
*i = r.get_int64();
return ok;
}
return Z3_FALSE;
Z3_CATCH_RETURN(Z3_FALSE);
return false;
Z3_CATCH_RETURN(false);
}
Z3_bool Z3_API Z3_get_numeral_rational_int64(Z3_context c, Z3_ast v, int64_t* num, int64_t* den) {
bool Z3_API Z3_get_numeral_rational_int64(Z3_context c, Z3_ast v, int64_t* num, int64_t* den) {
Z3_TRY;
// This function invokes Z3_get_numeral_rational, but it is still ok to add LOG command here because it does not return a Z3 object.
LOG_Z3_get_numeral_rational_int64(c, v, num, den);
RESET_ERROR_CODE();
CHECK_IS_EXPR(v, Z3_FALSE);
CHECK_IS_EXPR(v, false);
if (!num || !den) {
SET_ERROR_CODE(Z3_INVALID_ARG, nullptr);
return Z3_FALSE;
return false;
}
rational r;
Z3_bool ok = Z3_get_numeral_rational(c, v, r);
if (ok != Z3_TRUE) {
bool ok = Z3_get_numeral_rational(c, v, r);
if (ok != true) {
return ok;
}
rational n = numerator(r);
@ -385,11 +390,11 @@ extern "C" {
*den = d.get_int64();
return ok;
}
return Z3_FALSE;
Z3_CATCH_RETURN(Z3_FALSE);
return false;
Z3_CATCH_RETURN(false);
}
Z3_ast Z3_API Z3_mk_bv_numeral(Z3_context c, unsigned sz, Z3_bool const* bits) {
Z3_ast Z3_API Z3_mk_bv_numeral(Z3_context c, unsigned sz, bool const* bits) {
Z3_TRY;
LOG_Z3_mk_bv_numeral(c, sz, bits);
RESET_ERROR_CODE();

View file

@ -124,10 +124,16 @@ extern "C" {
}
Z3_lbool Z3_API Z3_optimize_check(Z3_context c, Z3_optimize o) {
Z3_lbool Z3_API Z3_optimize_check(Z3_context c, Z3_optimize o, unsigned num_assumptions, Z3_ast const assumptions[]) {
Z3_TRY;
LOG_Z3_optimize_check(c, o);
LOG_Z3_optimize_check(c, o, num_assumptions, assumptions);
RESET_ERROR_CODE();
for (unsigned i = 0; i < num_assumptions; i++) {
if (!is_expr(to_ast(assumptions[i]))) {
SET_ERROR_CODE(Z3_INVALID_ARG, "assumption is not an expression");
return Z3_L_UNDEF;
}
}
lbool r = l_undef;
cancel_eh<reslimit> eh(mk_c(c)->m().limit());
unsigned timeout = to_optimize_ptr(o)->get_params().get_uint("timeout", mk_c(c)->get_timeout());
@ -137,7 +143,9 @@ extern "C" {
scoped_timer timer(timeout, &eh);
scoped_rlimit _rlimit(mk_c(c)->m().limit(), rlimit);
try {
r = to_optimize_ptr(o)->optimize();
expr_ref_vector asms(mk_c(c)->m());
asms.append(num_assumptions, to_exprs(assumptions));
r = to_optimize_ptr(o)->optimize(asms);
}
catch (z3_exception& ex) {
if (!mk_c(c)->m().canceled()) {
@ -157,6 +165,22 @@ extern "C" {
Z3_CATCH_RETURN(Z3_L_UNDEF);
}
Z3_ast_vector Z3_API Z3_optimize_get_unsat_core(Z3_context c, Z3_optimize o) {
Z3_TRY;
LOG_Z3_optimize_get_unsat_core(c, o);
RESET_ERROR_CODE();
expr_ref_vector core(mk_c(c)->m());
to_optimize_ptr(o)->get_unsat_core(core);
Z3_ast_vector_ref * v = alloc(Z3_ast_vector_ref, *mk_c(c), mk_c(c)->m());
mk_c(c)->save_object(v);
for (expr* e : core) {
v->m_ast_vector.push_back(e);
}
RETURN_Z3(of_ast_vector(v));
Z3_CATCH_RETURN(nullptr);
}
Z3_string Z3_API Z3_optimize_get_reason_unknown(Z3_context c, Z3_optimize o) {
Z3_TRY;
LOG_Z3_optimize_to_string(c, o);
@ -330,10 +354,8 @@ extern "C" {
return;
}
ptr_vector<expr>::const_iterator it = ctx->begin_assertions();
ptr_vector<expr>::const_iterator end = ctx->end_assertions();
for (; it != end; ++it) {
to_optimize_ptr(opt)->add_hard_constraint(*it);
for (expr * e : ctx->assertions()) {
to_optimize_ptr(opt)->add_hard_constraint(e);
}
}

View file

@ -62,11 +62,11 @@ extern "C" {
/**
\brief Add a Boolean parameter \c k with value \c v to the parameter set \c p.
*/
void Z3_API Z3_params_set_bool(Z3_context c, Z3_params p, Z3_symbol k, Z3_bool v) {
void Z3_API Z3_params_set_bool(Z3_context c, Z3_params p, Z3_symbol k, bool v) {
Z3_TRY;
LOG_Z3_params_set_bool(c, p, k, v);
RESET_ERROR_CODE();
to_params(p)->m_params.set_bool(norm_param_name(to_symbol(k)).c_str(), v != 0);
to_params(p)->m_params.set_bool(norm_param_name(to_symbol(k)).c_str(), v);
Z3_CATCH;
}

View file

@ -71,10 +71,8 @@ extern "C" {
SET_ERROR_CODE(Z3_PARSER_ERROR, errstrm.str().c_str());
return of_ast_vector(v);
}
ptr_vector<expr>::const_iterator it = ctx->begin_assertions();
ptr_vector<expr>::const_iterator end = ctx->end_assertions();
for (; it != end; ++it) {
v->m_ast_vector.push_back(*it);
for (expr * e : ctx->assertions()) {
v->m_ast_vector.push_back(e);
}
return of_ast_vector(v);
Z3_CATCH_RETURN(nullptr);

View file

@ -1,5 +1,5 @@
/*++
Copyright (c) Microsoft Corporation, Arive Gurfinkel 2017
Copyright (c) Microsoft Corporation, Arie Gurfinkel 2017
Module Name:

View file

@ -26,7 +26,7 @@ extern "C" {
Z3_ast Z3_API Z3_mk_quantifier(
Z3_context c,
Z3_bool is_forall,
bool is_forall,
unsigned weight,
unsigned num_patterns, Z3_pattern const patterns[],
unsigned num_decls, Z3_sort const sorts[],
@ -50,7 +50,7 @@ extern "C" {
Z3_ast mk_quantifier_ex_core(
Z3_context c,
Z3_bool is_forall,
bool is_forall,
unsigned weight,
Z3_symbol quantifier_id,
Z3_symbol skolem_id,
@ -109,7 +109,7 @@ extern "C" {
Z3_ast Z3_API Z3_mk_quantifier_ex(
Z3_context c,
Z3_bool is_forall,
bool is_forall,
unsigned weight,
Z3_symbol quantifier_id,
Z3_symbol skolem_id,
@ -132,7 +132,7 @@ extern "C" {
unsigned num_decls, Z3_sort const types[],
Z3_symbol const decl_names[],
Z3_ast body) {
return Z3_mk_quantifier(c, 1, weight, num_patterns, patterns, num_decls, types, decl_names, body);
return Z3_mk_quantifier(c, true, weight, num_patterns, patterns, num_decls, types, decl_names, body);
}
Z3_ast Z3_API Z3_mk_exists(Z3_context c,
@ -141,7 +141,7 @@ extern "C" {
unsigned num_decls, Z3_sort const types[],
Z3_symbol const decl_names[],
Z3_ast body) {
return Z3_mk_quantifier(c, 0, weight, num_patterns, patterns, num_decls, types, decl_names, body);
return Z3_mk_quantifier(c, false, weight, num_patterns, patterns, num_decls, types, decl_names, body);
}
Z3_ast Z3_API Z3_mk_lambda(Z3_context c,
@ -155,7 +155,7 @@ extern "C" {
expr_ref result(mk_c(c)->m());
if (num_decls == 0) {
SET_ERROR_CODE(Z3_INVALID_USAGE, nullptr);
RETURN_Z3(0);
RETURN_Z3(nullptr);
}
sort* const* ts = reinterpret_cast<sort * const*>(types);
@ -166,7 +166,7 @@ extern "C" {
result = mk_c(c)->m().mk_lambda(names.size(), ts, names.c_ptr(), to_expr(body));
mk_c(c)->save_ast_trail(result.get());
return of_ast(result.get());
Z3_CATCH_RETURN(0);
Z3_CATCH_RETURN(nullptr);
}
Z3_ast Z3_API Z3_mk_lambda_const(Z3_context c,
@ -178,7 +178,7 @@ extern "C" {
RESET_ERROR_CODE();
if (num_decls == 0) {
SET_ERROR_CODE(Z3_INVALID_USAGE, nullptr);
RETURN_Z3(0);
RETURN_Z3(nullptr);
}
svector<symbol> _names;
@ -196,12 +196,12 @@ extern "C" {
result = mk_c(c)->m().mk_lambda(_vars.size(), _vars.c_ptr(), _names.c_ptr(), result);
mk_c(c)->save_ast_trail(result.get());
return of_ast(result.get());
Z3_CATCH_RETURN(0);
Z3_CATCH_RETURN(nullptr);
}
Z3_ast Z3_API Z3_mk_quantifier_const_ex(Z3_context c,
Z3_bool is_forall,
bool is_forall,
unsigned weight,
Z3_symbol quantifier_id,
Z3_symbol skolem_id,
@ -283,7 +283,7 @@ extern "C" {
}
Z3_ast Z3_API Z3_mk_quantifier_const(Z3_context c,
Z3_bool is_forall,
bool is_forall,
unsigned weight,
unsigned num_bound,
Z3_app const bound[],
@ -343,28 +343,28 @@ extern "C" {
Z3_CATCH_RETURN(nullptr);
}
Z3_bool Z3_API Z3_is_quantifier_forall(Z3_context c, Z3_ast a) {
bool Z3_API Z3_is_quantifier_forall(Z3_context c, Z3_ast a) {
Z3_TRY;
LOG_Z3_is_quantifier_forall(c, a);
RESET_ERROR_CODE();
return ::is_forall(to_ast(a)) ? Z3_TRUE : Z3_FALSE;
Z3_CATCH_RETURN(Z3_FALSE);
return ::is_forall(to_ast(a));
Z3_CATCH_RETURN(false);
}
Z3_bool Z3_API Z3_is_quantifier_exists(Z3_context c, Z3_ast a) {
bool Z3_API Z3_is_quantifier_exists(Z3_context c, Z3_ast a) {
Z3_TRY;
LOG_Z3_is_quantifier_exists(c, a);
RESET_ERROR_CODE();
return ::is_exists(to_ast(a)) ? Z3_TRUE : Z3_FALSE;
Z3_CATCH_RETURN(Z3_FALSE);
return ::is_exists(to_ast(a));
Z3_CATCH_RETURN(false);
}
Z3_bool Z3_API Z3_is_lambda(Z3_context c, Z3_ast a) {
bool Z3_API Z3_is_lambda(Z3_context c, Z3_ast a) {
Z3_TRY;
LOG_Z3_is_lambda(c, a);
RESET_ERROR_CODE();
return ::is_lambda(to_ast(a)) ? Z3_TRUE : Z3_FALSE;
Z3_CATCH_RETURN(Z3_FALSE);
return ::is_lambda(to_ast(a));
Z3_CATCH_RETURN(false);
}

View file

@ -214,67 +214,67 @@ extern "C" {
Z3_CATCH_RETURN(nullptr);
}
Z3_bool Z3_API Z3_rcf_lt(Z3_context c, Z3_rcf_num a, Z3_rcf_num b) {
bool Z3_API Z3_rcf_lt(Z3_context c, Z3_rcf_num a, Z3_rcf_num b) {
Z3_TRY;
LOG_Z3_rcf_lt(c, a, b);
RESET_ERROR_CODE();
reset_rcf_cancel(c);
return rcfm(c).lt(to_rcnumeral(a), to_rcnumeral(b));
Z3_CATCH_RETURN(Z3_FALSE);
Z3_CATCH_RETURN(false);
}
Z3_bool Z3_API Z3_rcf_gt(Z3_context c, Z3_rcf_num a, Z3_rcf_num b) {
bool Z3_API Z3_rcf_gt(Z3_context c, Z3_rcf_num a, Z3_rcf_num b) {
Z3_TRY;
LOG_Z3_rcf_gt(c, a, b);
RESET_ERROR_CODE();
reset_rcf_cancel(c);
return rcfm(c).gt(to_rcnumeral(a), to_rcnumeral(b));
Z3_CATCH_RETURN(Z3_FALSE);
Z3_CATCH_RETURN(false);
}
Z3_bool Z3_API Z3_rcf_le(Z3_context c, Z3_rcf_num a, Z3_rcf_num b) {
bool Z3_API Z3_rcf_le(Z3_context c, Z3_rcf_num a, Z3_rcf_num b) {
Z3_TRY;
LOG_Z3_rcf_le(c, a, b);
RESET_ERROR_CODE();
reset_rcf_cancel(c);
return rcfm(c).le(to_rcnumeral(a), to_rcnumeral(b));
Z3_CATCH_RETURN(Z3_FALSE);
Z3_CATCH_RETURN(false);
}
Z3_bool Z3_API Z3_rcf_ge(Z3_context c, Z3_rcf_num a, Z3_rcf_num b) {
bool Z3_API Z3_rcf_ge(Z3_context c, Z3_rcf_num a, Z3_rcf_num b) {
Z3_TRY;
LOG_Z3_rcf_ge(c, a, b);
RESET_ERROR_CODE();
reset_rcf_cancel(c);
return rcfm(c).ge(to_rcnumeral(a), to_rcnumeral(b));
Z3_CATCH_RETURN(Z3_FALSE);
Z3_CATCH_RETURN(false);
}
Z3_bool Z3_API Z3_rcf_eq(Z3_context c, Z3_rcf_num a, Z3_rcf_num b) {
bool Z3_API Z3_rcf_eq(Z3_context c, Z3_rcf_num a, Z3_rcf_num b) {
Z3_TRY;
LOG_Z3_rcf_eq(c, a, b);
RESET_ERROR_CODE();
reset_rcf_cancel(c);
return rcfm(c).eq(to_rcnumeral(a), to_rcnumeral(b));
Z3_CATCH_RETURN(Z3_FALSE);
Z3_CATCH_RETURN(false);
}
Z3_bool Z3_API Z3_rcf_neq(Z3_context c, Z3_rcf_num a, Z3_rcf_num b) {
bool Z3_API Z3_rcf_neq(Z3_context c, Z3_rcf_num a, Z3_rcf_num b) {
Z3_TRY;
LOG_Z3_rcf_neq(c, a, b);
RESET_ERROR_CODE();
reset_rcf_cancel(c);
return rcfm(c).neq(to_rcnumeral(a), to_rcnumeral(b));
Z3_CATCH_RETURN(Z3_FALSE);
Z3_CATCH_RETURN(false);
}
Z3_string Z3_API Z3_rcf_num_to_string(Z3_context c, Z3_rcf_num a, Z3_bool compact, Z3_bool html) {
Z3_string Z3_API Z3_rcf_num_to_string(Z3_context c, Z3_rcf_num a, bool compact, bool html) {
Z3_TRY;
LOG_Z3_rcf_num_to_string(c, a, compact, html);
RESET_ERROR_CODE();
reset_rcf_cancel(c);
std::ostringstream buffer;
rcfm(c).display(buffer, to_rcnumeral(a), compact != 0, html != 0);
rcfm(c).display(buffer, to_rcnumeral(a), compact, html);
return mk_c(c)->mk_external_string(buffer.str());
Z3_CATCH_RETURN("");
}

View file

@ -65,40 +65,36 @@ extern "C" {
Z3_CATCH_RETURN(nullptr);
}
Z3_bool Z3_API Z3_is_seq_sort(Z3_context c, Z3_sort s) {
bool Z3_API Z3_is_seq_sort(Z3_context c, Z3_sort s) {
Z3_TRY;
LOG_Z3_is_seq_sort(c, s);
RESET_ERROR_CODE();
bool result = mk_c(c)->sutil().is_seq(to_sort(s));
return result?Z3_TRUE:Z3_FALSE;
Z3_CATCH_RETURN(Z3_FALSE);
return mk_c(c)->sutil().is_seq(to_sort(s));
Z3_CATCH_RETURN(false);
}
Z3_bool Z3_API Z3_is_re_sort(Z3_context c, Z3_sort s) {
bool Z3_API Z3_is_re_sort(Z3_context c, Z3_sort s) {
Z3_TRY;
LOG_Z3_is_re_sort(c, s);
RESET_ERROR_CODE();
bool result = mk_c(c)->sutil().is_re(to_sort(s));
return result?Z3_TRUE:Z3_FALSE;
Z3_CATCH_RETURN(Z3_FALSE);
return mk_c(c)->sutil().is_re(to_sort(s));
Z3_CATCH_RETURN(false);
}
Z3_bool Z3_API Z3_is_string_sort(Z3_context c, Z3_sort s) {
bool Z3_API Z3_is_string_sort(Z3_context c, Z3_sort s) {
Z3_TRY;
LOG_Z3_is_string_sort(c, s);
RESET_ERROR_CODE();
bool result = mk_c(c)->sutil().is_string(to_sort(s));
return result?Z3_TRUE:Z3_FALSE;
Z3_CATCH_RETURN(Z3_FALSE);
return mk_c(c)->sutil().is_string(to_sort(s));
Z3_CATCH_RETURN(false);
}
Z3_bool Z3_API Z3_is_string(Z3_context c, Z3_ast s) {
bool Z3_API Z3_is_string(Z3_context c, Z3_ast s) {
Z3_TRY;
LOG_Z3_is_string(c, s);
RESET_ERROR_CODE();
bool result = mk_c(c)->sutil().str.is_string(to_expr(s));
return result?Z3_TRUE:Z3_FALSE;
Z3_CATCH_RETURN(Z3_FALSE);
return mk_c(c)->sutil().str.is_string(to_expr(s));
Z3_CATCH_RETURN(false);
}
Z3_string Z3_API Z3_get_string(Z3_context c, Z3_ast s) {
@ -110,8 +106,8 @@ extern "C" {
SET_ERROR_CODE(Z3_INVALID_ARG, "expression is not a string literal");
return "";
}
std::string result = str.encode();
return mk_c(c)->mk_external_string(result);
std::string s = str.encode();
return mk_c(c)->mk_external_string(s);
Z3_CATCH_RETURN("");
}

View file

@ -157,10 +157,8 @@ extern "C" {
bool initialized = to_solver(s)->m_solver.get() != nullptr;
if (!initialized)
init_solver(c, s);
ptr_vector<expr>::const_iterator it = ctx->begin_assertions();
ptr_vector<expr>::const_iterator end = ctx->end_assertions();
for (; it != end; ++it) {
to_solver_ref(s)->assert_expr(*it);
for (expr * e : ctx->assertions()) {
to_solver_ref(s)->assert_expr(e);
}
to_solver_ref(s)->set_model_converter(ctx->get_model_converter());
}
@ -179,16 +177,24 @@ extern "C" {
LOG_Z3_solver_from_file(c, s, file_name);
char const* ext = get_extension(file_name);
std::ifstream is(file_name);
init_solver(c, s);
if (!is) {
SET_ERROR_CODE(Z3_FILE_ACCESS_ERROR, nullptr);
}
else if (ext && std::string("dimacs") == ext) {
ast_manager& m = to_solver_ref(s)->get_manager();
std::stringstream err;
sat::solver solver(to_solver_ref(s)->get_params(), m.limit());
parse_dimacs(is, solver);
if (!parse_dimacs(is, err, solver)) {
SET_ERROR_CODE(Z3_PARSER_ERROR, err.str().c_str());
return;
}
sat2goal s2g;
ref<sat2goal::mc> mc;
atom2bool_var a2b(m);
for (unsigned v = 0; v < solver.num_vars(); ++v) {
a2b.insert(m.mk_const(symbol(v), m.mk_bool_sort()), v);
}
goal g(m);
s2g(solver, a2b, to_solver_ref(s)->get_params(), g, mc);
for (unsigned i = 0; i < g.size(); ++i) {
@ -368,7 +374,22 @@ extern "C" {
v->m_ast_vector.push_back(f);
}
RETURN_Z3(of_ast_vector(v));
Z3_CATCH_RETURN(0);
Z3_CATCH_RETURN(nullptr);
}
Z3_ast_vector Z3_API Z3_solver_get_non_units(Z3_context c, Z3_solver s) {
Z3_TRY;
LOG_Z3_solver_get_non_units(c, s);
RESET_ERROR_CODE();
init_solver(c, s);
Z3_ast_vector_ref * v = alloc(Z3_ast_vector_ref, *mk_c(c), mk_c(c)->m());
mk_c(c)->save_object(v);
expr_ref_vector fmls = to_solver_ref(s)->get_non_units(mk_c(c)->m());
for (expr* f : fmls) {
v->m_ast_vector.push_back(f);
}
RETURN_Z3(of_ast_vector(v));
Z3_CATCH_RETURN(nullptr);
}
static Z3_lbool _solver_check(Z3_context c, Z3_solver s, unsigned num_assumptions, Z3_ast const assumptions[]) {
@ -615,7 +636,7 @@ extern "C" {
}
catch (z3_exception & ex) {
mk_c(c)->handle_exception(ex);
return 0;
return nullptr;
}
}
Z3_ast_vector_ref * v = alloc(Z3_ast_vector_ref, *mk_c(c), mk_c(c)->m());
@ -628,7 +649,7 @@ extern "C" {
to_ast_vector_ref(vs).push_back(a);
}
RETURN_Z3(of_ast_vector(v));
Z3_CATCH_RETURN(0);
Z3_CATCH_RETURN(nullptr);
}

View file

@ -74,28 +74,28 @@ extern "C" {
Z3_CATCH_RETURN("");
}
Z3_bool Z3_API Z3_stats_is_uint(Z3_context c, Z3_stats s, unsigned idx) {
bool Z3_API Z3_stats_is_uint(Z3_context c, Z3_stats s, unsigned idx) {
Z3_TRY;
LOG_Z3_stats_is_uint(c, s, idx);
RESET_ERROR_CODE();
if (idx >= to_stats_ref(s).size()) {
SET_ERROR_CODE(Z3_IOB, nullptr);
return Z3_FALSE;
return false;
}
return to_stats_ref(s).is_uint(idx);
Z3_CATCH_RETURN(0);
}
Z3_bool Z3_API Z3_stats_is_double(Z3_context c, Z3_stats s, unsigned idx) {
bool Z3_API Z3_stats_is_double(Z3_context c, Z3_stats s, unsigned idx) {
Z3_TRY;
LOG_Z3_stats_is_double(c, s, idx);
RESET_ERROR_CODE();
if (idx >= to_stats_ref(s).size()) {
SET_ERROR_CODE(Z3_IOB, nullptr);
return Z3_FALSE;
return false;
}
return !to_stats_ref(s).is_uint(idx);
Z3_CATCH_RETURN(Z3_FALSE);
Z3_CATCH_RETURN(false);
}
unsigned Z3_API Z3_stats_get_uint_value(Z3_context c, Z3_stats s, unsigned idx) {

File diff suppressed because it is too large Load diff

View file

@ -17,17 +17,16 @@ Notes:
--*/
using System.Diagnostics;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// The abstract syntax tree (AST) class.
/// </summary>
[ContractVerification(true)]
public class AST : Z3Object, IComparable
{
/// <summary>
@ -114,8 +113,7 @@ namespace Microsoft.Z3
/// <returns>A copy of the AST which is associated with <paramref name="ctx"/></returns>
public AST Translate(Context ctx)
{
Contract.Requires(ctx != null);
Contract.Ensures(Contract.Result<AST>() != null);
Debug.Assert(ctx != null);
if (ReferenceEquals(Context, ctx))
return this;
@ -202,14 +200,13 @@ namespace Microsoft.Z3
/// </summary>
public string SExpr()
{
Contract.Ensures(Contract.Result<string>() != null);
return Native.Z3_ast_to_string(Context.nCtx, NativeObject);
}
#region Internal
internal AST(Context ctx) : base(ctx) { Contract.Requires(ctx != null); }
internal AST(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
internal AST(Context ctx) : base(ctx) { Debug.Assert(ctx != null); }
internal AST(Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx != null); }
internal class DecRefQueue : IDecRefQueue
{
@ -246,8 +243,7 @@ namespace Microsoft.Z3
internal static AST Create(Context ctx, IntPtr obj)
{
Contract.Requires(ctx != null);
Contract.Ensures(Contract.Result<AST>() != null);
Debug.Assert(ctx != null);
switch ((Z3_ast_kind)Native.Z3_get_ast_kind(ctx.nCtx, obj))
{

View file

@ -17,15 +17,14 @@ Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// Map from AST to AST
/// </summary>
[ContractVerification(true)]
internal class ASTMap : Z3Object
{
/// <summary>
@ -35,7 +34,7 @@ namespace Microsoft.Z3
/// <returns>True if <paramref name="k"/> is a key in the map, false otherwise.</returns>
public bool Contains(AST k)
{
Contract.Requires(k != null);
Debug.Assert(k != null);
return 0 != Native.Z3_ast_map_contains(Context.nCtx, NativeObject, k.NativeObject);
}
@ -49,8 +48,7 @@ namespace Microsoft.Z3
/// <param name="k">An AST</param>
public AST Find(AST k)
{
Contract.Requires(k != null);
Contract.Ensures(Contract.Result<AST>() != null);
Debug.Assert(k != null);
return new AST(Context, Native.Z3_ast_map_find(Context.nCtx, NativeObject, k.NativeObject));
}
@ -62,8 +60,8 @@ namespace Microsoft.Z3
/// <param name="v">The value AST</param>
public void Insert(AST k, AST v)
{
Contract.Requires(k != null);
Contract.Requires(v != null);
Debug.Assert(k != null);
Debug.Assert(v != null);
Native.Z3_ast_map_insert(Context.nCtx, NativeObject, k.NativeObject, v.NativeObject);
}
@ -74,7 +72,7 @@ namespace Microsoft.Z3
/// <param name="k">An AST</param>
public void Erase(AST k)
{
Contract.Requires(k != null);
Debug.Assert(k != null);
Native.Z3_ast_map_erase(Context.nCtx, NativeObject, k.NativeObject);
}
@ -119,12 +117,12 @@ namespace Microsoft.Z3
internal ASTMap(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
internal ASTMap(Context ctx)
: base(ctx, Native.Z3_mk_ast_map(ctx.nCtx))
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
internal class DecRefQueue : IDecRefQueue

View file

@ -17,8 +17,8 @@ Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
@ -45,13 +45,12 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<AST>() != null);
return new AST(Context, Native.Z3_ast_vector_get(Context.nCtx, NativeObject, i));
}
set
{
Contract.Requires(value != null);
Debug.Assert(value != null);
Native.Z3_ast_vector_set(Context.nCtx, NativeObject, i, value.NativeObject);
}
@ -73,7 +72,7 @@ namespace Microsoft.Z3
/// <param name="a">An AST</param>
public void Push(AST a)
{
Contract.Requires(a != null);
Debug.Assert(a != null);
Native.Z3_ast_vector_push(Context.nCtx, NativeObject, a.NativeObject);
}
@ -85,8 +84,7 @@ namespace Microsoft.Z3
/// <returns>A new ASTVector</returns>
public ASTVector Translate(Context ctx)
{
Contract.Requires(ctx != null);
Contract.Ensures(Contract.Result<ASTVector>() != null);
Debug.Assert(ctx != null);
return new ASTVector(Context, Native.Z3_ast_vector_translate(Context.nCtx, NativeObject, ctx.nCtx));
}
@ -232,8 +230,8 @@ namespace Microsoft.Z3
}
#region Internal
internal ASTVector(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
internal ASTVector(Context ctx) : base(ctx, Native.Z3_mk_ast_vector(ctx.nCtx)) { Contract.Requires(ctx != null); }
internal ASTVector(Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx != null); }
internal ASTVector(Context ctx) : base(ctx, Native.Z3_mk_ast_vector(ctx.nCtx)) { Debug.Assert(ctx != null); }
internal class DecRefQueue : IDecRefQueue
{

View file

@ -16,8 +16,8 @@ Author:
Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
#if !FRAMEWORK_LT_4
using System.Numerics;
@ -28,7 +28,6 @@ namespace Microsoft.Z3
/// <summary>
/// Algebraic numbers
/// </summary>
[ContractVerification(true)]
public class AlgebraicNum : ArithExpr
{
/// <summary>
@ -40,7 +39,6 @@ namespace Microsoft.Z3
/// <returns>A numeral Expr of sort Real</returns>
public RatNum ToUpper(uint precision)
{
Contract.Ensures(Contract.Result<RatNum>() != null);
return new RatNum(Context, Native.Z3_get_algebraic_number_upper(Context.nCtx, NativeObject, precision));
}
@ -54,7 +52,6 @@ namespace Microsoft.Z3
/// <returns>A numeral Expr of sort Real</returns>
public RatNum ToLower(uint precision)
{
Contract.Ensures(Contract.Result<RatNum>() != null);
return new RatNum(Context, Native.Z3_get_algebraic_number_lower(Context.nCtx, NativeObject, precision));
}
@ -65,7 +62,6 @@ namespace Microsoft.Z3
/// <remarks>The result has at most <paramref name="precision"/> decimal places.</remarks>
public string ToDecimal(uint precision)
{
Contract.Ensures(Contract.Result<string>() != null);
return Native.Z3_get_numeral_decimal_string(Context.nCtx, NativeObject, precision);
}
@ -74,7 +70,7 @@ namespace Microsoft.Z3
internal AlgebraicNum(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
#endregion
}

View file

@ -17,8 +17,8 @@ Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
@ -26,7 +26,6 @@ namespace Microsoft.Z3
/// ApplyResult objects represent the result of an application of a
/// tactic to a goal. It contains the subgoals that were produced.
/// </summary>
[ContractVerification(true)]
public class ApplyResult : Z3Object
{
/// <summary>
@ -44,8 +43,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<Goal[]>() != null);
Contract.Ensures(Contract.Result<Goal[]>().Length == this.NumSubgoals);
uint n = NumSubgoals;
Goal[] res = new Goal[n];
@ -67,7 +64,7 @@ namespace Microsoft.Z3
internal ApplyResult(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
internal class DecRefQueue : IDecRefQueue

View file

@ -16,12 +16,12 @@ Author:
Notes:
--*/
using System.Diagnostics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
@ -35,7 +35,7 @@ namespace Microsoft.Z3
internal ArithExpr(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
#endregion
@ -45,7 +45,7 @@ namespace Microsoft.Z3
private static ArithExpr MkNum(ArithExpr e, double d) { return (ArithExpr)e.Context.MkNumeral(d.ToString(), e.Context.MkRealSort()); }
/// <summary> Operator overloading for arithmetical divsion operator (over reals) </summary>
/// <summary> Operator overloading for arithmetical division operator (over reals) </summary>
public static ArithExpr operator /(ArithExpr a, ArithExpr b) { return a.Context.MkDiv(a, b); }
/// <summary> Operator overloading for arithmetical operator </summary>

View file

@ -17,8 +17,8 @@ Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
@ -28,7 +28,7 @@ namespace Microsoft.Z3
public class ArithSort : Sort
{
#region Internal
internal ArithSort(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
internal ArithSort(Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx != null); }
#endregion
};
}

View file

@ -16,12 +16,12 @@ Author:
Notes:
--*/
using System.Diagnostics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
@ -35,7 +35,7 @@ namespace Microsoft.Z3
internal ArrayExpr(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
#endregion
}

View file

@ -17,15 +17,14 @@ Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// Array sorts.
/// </summary>
[ContractVerification(true)]
public class ArraySort : Sort
{
/// <summary>
@ -35,7 +34,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<Sort>() != null);
return Sort.Create(Context, Native.Z3_get_array_sort_domain(Context.nCtx, NativeObject));
}
@ -48,27 +46,26 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<Sort>() != null);
return Sort.Create(Context, Native.Z3_get_array_sort_range(Context.nCtx, NativeObject));
}
}
#region Internal
internal ArraySort(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
internal ArraySort(Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx != null); }
internal ArraySort(Context ctx, Sort domain, Sort range)
: base(ctx, Native.Z3_mk_array_sort(ctx.nCtx, domain.NativeObject, range.NativeObject))
{
Contract.Requires(ctx != null);
Contract.Requires(domain != null);
Contract.Requires(range != null);
Debug.Assert(ctx != null);
Debug.Assert(domain != null);
Debug.Assert(range != null);
}
internal ArraySort(Context ctx, Sort[] domain, Sort range)
: base(ctx, Native.Z3_mk_array_sort_n(ctx.nCtx, (uint)domain.Length, AST.ArrayToNative(domain), range.NativeObject))
{
Contract.Requires(ctx != null);
Contract.Requires(domain != null);
Contract.Requires(range != null);
Debug.Assert(ctx != null);
Debug.Assert(domain != null);
Debug.Assert(range != null);
}
#endregion
};

View file

@ -16,12 +16,12 @@ Author:
Notes:
--*/
using System.Diagnostics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
@ -41,7 +41,7 @@ namespace Microsoft.Z3
#region Internal
/// <summary> Constructor for BitVecExpr </summary>
internal BitVecExpr(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
internal BitVecExpr(Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx != null); }
#endregion
}
}

View file

@ -16,8 +16,8 @@ Author:
Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
#if !FRAMEWORK_LT_4
using System.Numerics;
@ -28,7 +28,6 @@ namespace Microsoft.Z3
/// <summary>
/// Bit-vector numerals
/// </summary>
[ContractVerification(true)]
public class BitVecNum : BitVecExpr
{
/// <summary>
@ -109,7 +108,7 @@ namespace Microsoft.Z3
}
#region Internal
internal BitVecNum(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
internal BitVecNum(Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx != null); }
#endregion
}
}

View file

@ -17,8 +17,8 @@ Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
@ -36,7 +36,7 @@ namespace Microsoft.Z3
}
#region Internal
internal BitVecSort(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
internal BitVecSort(Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx != null); }
#endregion
};
}

View file

@ -16,12 +16,12 @@ Author:
Notes:
--*/
using System.Diagnostics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
@ -32,7 +32,7 @@ namespace Microsoft.Z3
{
#region Internal
/// <summary> Constructor for BoolExpr </summary>
internal BoolExpr(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
internal BoolExpr(Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx != null); }
#endregion
#region Operators

View file

@ -17,8 +17,8 @@ Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
@ -28,8 +28,8 @@ namespace Microsoft.Z3
public class BoolSort : Sort
{
#region Internal
internal BoolSort(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
internal BoolSort(Context ctx) : base(ctx, Native.Z3_mk_bool_sort(ctx.nCtx)) { Contract.Requires(ctx != null); }
internal BoolSort(Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx != null); }
internal BoolSort(Context ctx) : base(ctx, Native.Z3_mk_bool_sort(ctx.nCtx)) { Debug.Assert(ctx != null); }
#endregion
};
}

View file

@ -17,15 +17,14 @@ Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// Constructors are used for datatype sorts.
/// </summary>
[ContractVerification(true)]
public class Constructor : Z3Object
{
/// <summary>
@ -46,7 +45,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<FuncDecl>() != null);
IntPtr constructor = IntPtr.Zero;
IntPtr tester = IntPtr.Zero;
IntPtr[] accessors = new IntPtr[n];
@ -62,7 +60,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<FuncDecl>() != null);
IntPtr constructor = IntPtr.Zero;
IntPtr tester = IntPtr.Zero;
IntPtr[] accessors = new IntPtr[n];
@ -78,7 +75,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<FuncDecl[]>() != null);
IntPtr constructor = IntPtr.Zero;
IntPtr tester = IntPtr.Zero;
IntPtr[] accessors = new IntPtr[n];
@ -105,9 +101,9 @@ namespace Microsoft.Z3
Sort[] sorts, uint[] sortRefs)
: base(ctx)
{
Contract.Requires(ctx != null);
Contract.Requires(name != null);
Contract.Requires(recognizer != null);
Debug.Assert(ctx != null);
Debug.Assert(name != null);
Debug.Assert(recognizer != null);
n = AST.ArrayLength(fieldNames);

View file

@ -17,12 +17,12 @@ Notes:
--*/
using System.Diagnostics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
@ -43,14 +43,14 @@ namespace Microsoft.Z3
internal ConstructorList(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
internal ConstructorList(Context ctx, Constructor[] constructors)
: base(ctx)
{
Contract.Requires(ctx != null);
Contract.Requires(constructors != null);
Debug.Assert(ctx != null);
Debug.Assert(constructors != null);
NativeObject = Native.Z3_mk_constructor_list(Context.nCtx, (uint)constructors.Length, Constructor.ArrayToNative(constructors));
}

File diff suppressed because it is too large Load diff

View file

@ -16,12 +16,12 @@ Author:
Notes:
--*/
using System.Diagnostics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
@ -35,7 +35,7 @@ namespace Microsoft.Z3
internal DatatypeExpr(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
#endregion
}

View file

@ -17,15 +17,14 @@ Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// Datatype sorts.
/// </summary>
[ContractVerification(true)]
public class DatatypeSort : Sort
{
/// <summary>
@ -43,7 +42,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<FuncDecl[]>() != null);
uint n = NumConstructors;
FuncDecl[] res = new FuncDecl[n];
@ -60,7 +58,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<FuncDecl[]>() != null);
uint n = NumConstructors;
FuncDecl[] res = new FuncDecl[n];
@ -77,7 +74,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<FuncDecl[][]>() != null);
uint n = NumConstructors;
FuncDecl[][] res = new FuncDecl[n][];
@ -95,14 +91,14 @@ namespace Microsoft.Z3
}
#region Internal
internal DatatypeSort(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
internal DatatypeSort(Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx != null); }
internal DatatypeSort(Context ctx, Symbol name, Constructor[] constructors)
: base(ctx, Native.Z3_mk_datatype(ctx.nCtx, name.NativeObject, (uint)constructors.Length, ArrayToNative(constructors)))
{
Contract.Requires(ctx != null);
Contract.Requires(name != null);
Contract.Requires(constructors != null);
Debug.Assert(ctx != null);
Debug.Assert(name != null);
Debug.Assert(constructors != null);
}
#endregion
};

View file

@ -17,17 +17,16 @@ Author:
Notes:
--*/
using System.Diagnostics;
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// The main interaction with Z3 happens via the Context.
/// </summary>
[ContractVerification(true)]
public class Deprecated
{

View file

@ -17,15 +17,14 @@ Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// Enumeration sorts.
/// </summary>
[ContractVerification(true)]
public class EnumSort : Sort
{
/// <summary>
@ -35,7 +34,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<FuncDecl[]>() != null);
uint n = Native.Z3_get_datatype_sort_num_constructors(Context.nCtx, NativeObject);
FuncDecl[] t = new FuncDecl[n];
for (uint i = 0; i < n; i++)
@ -61,7 +59,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<Expr[]>() != null);
FuncDecl[] cds = ConstDecls;
Expr[] t = new Expr[cds.Length];
for (uint i = 0; i < t.Length; i++)
@ -87,7 +84,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<FuncDecl[]>() != null);
uint n = Native.Z3_get_datatype_sort_num_constructors(Context.nCtx, NativeObject);
FuncDecl[] t = new FuncDecl[n];
for (uint i = 0; i < n; i++)
@ -110,9 +106,9 @@ namespace Microsoft.Z3
internal EnumSort(Context ctx, Symbol name, Symbol[] enumNames)
: base(ctx, IntPtr.Zero)
{
Contract.Requires(ctx != null);
Contract.Requires(name != null);
Contract.Requires(enumNames != null);
Debug.Assert(ctx != null);
Debug.Assert(name != null);
Debug.Assert(enumNames != null);
int n = enumNames.Length;
IntPtr[] n_constdecls = new IntPtr[n];

View file

@ -17,15 +17,16 @@ Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
using System.Linq;
namespace Microsoft.Z3
{
/// <summary>
/// Expressions are terms.
/// </summary>
[ContractVerification(true)]
public class Expr : AST
{
/// <summary>
@ -35,7 +36,6 @@ namespace Microsoft.Z3
/// <seealso cref="Context.SimplifyHelp"/>
public Expr Simplify(Params p = null)
{
Contract.Ensures(Contract.Result<Expr>() != null);
if (p == null)
return Expr.Create(Context, Native.Z3_simplify(Context.nCtx, NativeObject));
@ -50,7 +50,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<FuncDecl>() != null);
return new FuncDecl(Context, Native.Z3_get_app_decl(Context.nCtx, NativeObject));
}
}
@ -79,7 +78,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<Expr[]>() != null);
uint n = NumArgs;
Expr[] res = new Expr[n];
@ -94,7 +92,6 @@ namespace Microsoft.Z3
/// </summary>
public Expr Arg(uint i)
{
Contract.Ensures(Contract.Result<Expr>() != null);
return Expr.Create(Context, Native.Z3_get_app_arg(Context.nCtx, NativeObject, i));
}
@ -104,8 +101,8 @@ namespace Microsoft.Z3
/// </summary>
public void Update(Expr[] args)
{
Contract.Requires(args != null);
Contract.Requires(Contract.ForAll(args, a => a != null));
Debug.Assert(args != null);
Debug.Assert(args.All(a => a != null));
Context.CheckContextMatch<Expr>(args);
if (IsApp && args.Length != NumArgs)
@ -123,11 +120,10 @@ namespace Microsoft.Z3
/// </remarks>
public Expr Substitute(Expr[] from, Expr[] to)
{
Contract.Requires(from != null);
Contract.Requires(to != null);
Contract.Requires(Contract.ForAll(from, f => f != null));
Contract.Requires(Contract.ForAll(to, t => t != null));
Contract.Ensures(Contract.Result<Expr>() != null);
Debug.Assert(from != null);
Debug.Assert(to != null);
Debug.Assert(from.All(f => f != null));
Debug.Assert(to.All(t => t != null));
Context.CheckContextMatch<Expr>(from);
Context.CheckContextMatch<Expr>(to);
@ -142,9 +138,8 @@ namespace Microsoft.Z3
/// <seealso cref="Substitute(Expr[],Expr[])"/>
public Expr Substitute(Expr from, Expr to)
{
Contract.Requires(from != null);
Contract.Requires(to != null);
Contract.Ensures(Contract.Result<Expr>() != null);
Debug.Assert(from != null);
Debug.Assert(to != null);
return Substitute(new Expr[] { from }, new Expr[] { to });
}
@ -157,9 +152,8 @@ namespace Microsoft.Z3
/// </remarks>
public Expr SubstituteVars(Expr[] to)
{
Contract.Requires(to != null);
Contract.Requires(Contract.ForAll(to, t => t != null));
Contract.Ensures(Contract.Result<Expr>() != null);
Debug.Assert(to != null);
Debug.Assert(to.All(t => t != null));
Context.CheckContextMatch<Expr>(to);
return Expr.Create(Context, Native.Z3_substitute_vars(Context.nCtx, NativeObject, (uint)to.Length, Expr.ArrayToNative(to)));
@ -207,7 +201,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<Sort>() != null);
return Sort.Create(Context, Native.Z3_get_sort(Context.nCtx, NativeObject));
}
}
@ -332,7 +325,7 @@ namespace Microsoft.Z3
/// <summary>
/// Retrieve bound of at-most
/// </summary>
public uint AtMostBound { get { Contract.Requires(IsAtMost); return (uint)FuncDecl.Parameters[0].Int; } }
public uint AtMostBound { get { Debug.Assert(IsAtMost); return (uint)FuncDecl.Parameters[0].Int; } }
/// <summary>
/// Indicates whether the term is at-least
@ -342,7 +335,7 @@ namespace Microsoft.Z3
/// <summary>
/// Retrieve bound of at-least
/// </summary>
public uint AtLeastBound { get { Contract.Requires(IsAtLeast); return (uint)FuncDecl.Parameters[0].Int; } }
public uint AtLeastBound { get { Debug.Assert(IsAtLeast); return (uint)FuncDecl.Parameters[0].Int; } }
/// <summary>
/// Indicates whether the term is pbeq
@ -842,7 +835,7 @@ namespace Microsoft.Z3
public string String { get { return Native.Z3_get_string(Context.nCtx, NativeObject); } }
/// <summary>
/// Check whether expression is a concatentation.
/// Check whether expression is a concatenation.
/// </summary>
/// <returns>a Boolean</returns>
public bool IsConcat { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_SEQ_CONCAT; } }
@ -1816,8 +1809,6 @@ namespace Microsoft.Z3
if (!IsVar)
throw new Z3Exception("Term is not a bound variable.");
Contract.EndContractBlock();
return Native.Z3_get_index_value(Context.nCtx, NativeObject);
}
}
@ -1827,10 +1818,9 @@ namespace Microsoft.Z3
/// <summary>
/// Constructor for Expr
/// </summary>
internal protected Expr(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
internal protected Expr(Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx != null); }
#if DEBUG
[Pure]
internal override void CheckNativeObject(IntPtr obj)
{
if (Native.Z3_is_app(Context.nCtx, obj) == 0 &&
@ -1841,12 +1831,10 @@ namespace Microsoft.Z3
}
#endif
[Pure]
internal static Expr Create(Context ctx, FuncDecl f, params Expr[] arguments)
{
Contract.Requires(ctx != null);
Contract.Requires(f != null);
Contract.Ensures(Contract.Result<Expr>() != null);
Debug.Assert(ctx != null);
Debug.Assert(f != null);
IntPtr obj = Native.Z3_mk_app(ctx.nCtx, f.NativeObject,
AST.ArrayLength(arguments),
@ -1854,11 +1842,9 @@ namespace Microsoft.Z3
return Create(ctx, obj);
}
[Pure]
new internal static Expr Create(Context ctx, IntPtr obj)
{
Contract.Requires(ctx != null);
Contract.Ensures(Contract.Result<Expr>() != null);
Debug.Assert(ctx != null);
Z3_ast_kind k = (Z3_ast_kind)Native.Z3_get_ast_kind(ctx.nCtx, obj);
if (k == Z3_ast_kind.Z3_QUANTIFIER_AST)

View file

@ -16,12 +16,12 @@ Author:
Notes:
--*/
using System.Diagnostics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
@ -45,7 +45,7 @@ namespace Microsoft.Z3
internal FPExpr(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
#endregion
}

View file

@ -16,15 +16,14 @@ Author:
Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// FloatiungPoint Numerals
/// </summary>
[ContractVerification(true)]
public class FPNum : FPExpr
{
/// <summary>
@ -175,7 +174,7 @@ namespace Microsoft.Z3
internal FPNum(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
#endregion

View file

@ -16,12 +16,12 @@ Author:
Notes:
--*/
using System.Diagnostics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
@ -35,7 +35,7 @@ namespace Microsoft.Z3
internal FPRMExpr(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
#endregion
}

View file

@ -16,12 +16,12 @@ Author:
Notes:
--*/
using System.Diagnostics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
@ -93,7 +93,7 @@ namespace Microsoft.Z3
internal FPRMNum(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
#endregion
}

View file

@ -17,8 +17,8 @@ Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
@ -31,12 +31,12 @@ namespace Microsoft.Z3
internal FPRMSort(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
internal FPRMSort(Context ctx)
: base(ctx, Native.Z3_mk_fpa_rounding_mode_sort(ctx.nCtx))
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
#endregion
}

View file

@ -16,8 +16,8 @@ Author:
Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
@ -40,12 +40,12 @@ namespace Microsoft.Z3
internal FPSort(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
internal FPSort(Context ctx, uint ebits, uint sbits)
: base(ctx, Native.Z3_mk_fpa_sort(ctx.nCtx, ebits, sbits))
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
#endregion
}

View file

@ -16,8 +16,8 @@ Author:
Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
@ -31,7 +31,7 @@ namespace Microsoft.Z3
internal FiniteDomainExpr(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
#endregion
}

View file

@ -16,8 +16,8 @@ Author:
Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
#if !FRAMEWORK_LT_4
using System.Numerics;
@ -28,7 +28,6 @@ namespace Microsoft.Z3
/// <summary>
/// Finite-domain numerals
/// </summary>
[ContractVerification(true)]
public class FiniteDomainNum : FiniteDomainExpr
{
/// <summary>
@ -109,7 +108,7 @@ namespace Microsoft.Z3
}
#region Internal
internal FiniteDomainNum(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
internal FiniteDomainNum(Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx != null); }
#endregion
}
}

View file

@ -17,15 +17,14 @@ Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// Finite domain sorts.
/// </summary>
[ContractVerification(true)]
public class FiniteDomainSort : Sort
{
/// <summary>
@ -45,13 +44,13 @@ namespace Microsoft.Z3
internal FiniteDomainSort(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
internal FiniteDomainSort(Context ctx, Symbol name, ulong size)
: base(ctx, Native.Z3_mk_finite_domain_sort(ctx.nCtx, name.NativeObject, size))
{
Contract.Requires(ctx != null);
Contract.Requires(name != null);
Debug.Assert(ctx != null);
Debug.Assert(name != null);
}
#endregion

View file

@ -18,14 +18,14 @@ Notes:
--*/
using System;
using System.Diagnostics.Contracts;
using System.Diagnostics;
using System.Linq;
namespace Microsoft.Z3
{
/// <summary>
/// Object for managing fixedpoints
/// </summary>
[ContractVerification(true)]
public class Fixedpoint : Z3Object
{
@ -36,7 +36,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<string>() != null);
return Native.Z3_fixedpoint_get_help(Context.nCtx, NativeObject);
}
}
@ -48,7 +47,7 @@ namespace Microsoft.Z3
{
set
{
Contract.Requires(value != null);
Debug.Assert(value != null);
Context.CheckContextMatch(value);
Native.Z3_fixedpoint_set_params(Context.nCtx, NativeObject, value.NativeObject);
}
@ -68,8 +67,8 @@ namespace Microsoft.Z3
/// </summary>
public void Assert(params BoolExpr[] constraints)
{
Contract.Requires(constraints != null);
Contract.Requires(Contract.ForAll(constraints, c => c != null));
Debug.Assert(constraints != null);
Debug.Assert(constraints.All(c => c != null));
Context.CheckContextMatch<BoolExpr>(constraints);
foreach (BoolExpr a in constraints)
@ -91,7 +90,7 @@ namespace Microsoft.Z3
/// </summary>
public void RegisterRelation(FuncDecl f)
{
Contract.Requires(f != null);
Debug.Assert(f != null);
Context.CheckContextMatch(f);
Native.Z3_fixedpoint_register_relation(Context.nCtx, NativeObject, f.NativeObject);
@ -102,7 +101,7 @@ namespace Microsoft.Z3
/// </summary>
public void AddRule(BoolExpr rule, Symbol name = null)
{
Contract.Requires(rule != null);
Debug.Assert(rule != null);
Context.CheckContextMatch(rule);
Native.Z3_fixedpoint_add_rule(Context.nCtx, NativeObject, rule.NativeObject, AST.GetNativeObject(name));
@ -113,8 +112,8 @@ namespace Microsoft.Z3
/// </summary>
public void AddFact(FuncDecl pred, params uint[] args)
{
Contract.Requires(pred != null);
Contract.Requires(args != null);
Debug.Assert(pred != null);
Debug.Assert(args != null);
Context.CheckContextMatch(pred);
Native.Z3_fixedpoint_add_fact(Context.nCtx, NativeObject, pred.NativeObject, (uint)args.Length, args);
@ -128,7 +127,7 @@ namespace Microsoft.Z3
/// </summary>
public Status Query(BoolExpr query)
{
Contract.Requires(query != null);
Debug.Assert(query != null);
Context.CheckContextMatch(query);
Z3_lbool r = (Z3_lbool)Native.Z3_fixedpoint_query(Context.nCtx, NativeObject, query.NativeObject);
@ -148,8 +147,8 @@ namespace Microsoft.Z3
/// </summary>
public Status Query(params FuncDecl[] relations)
{
Contract.Requires(relations != null);
Contract.Requires(Contract.ForAll(0, relations.Length, i => relations[i] != null));
Debug.Assert(relations != null);
Debug.Assert(relations.All(rel => rel != null));
Context.CheckContextMatch<FuncDecl>(relations);
Z3_lbool r = (Z3_lbool)Native.Z3_fixedpoint_query_relations(Context.nCtx, NativeObject,
@ -187,7 +186,7 @@ namespace Microsoft.Z3
/// </summary>
public void UpdateRule(BoolExpr rule, Symbol name)
{
Contract.Requires(rule != null);
Debug.Assert(rule != null);
Context.CheckContextMatch(rule);
Native.Z3_fixedpoint_update_rule(Context.nCtx, NativeObject, rule.NativeObject, AST.GetNativeObject(name));
@ -208,7 +207,6 @@ namespace Microsoft.Z3
/// </summary>
public string GetReasonUnknown()
{
Contract.Ensures(Contract.Result<string>() != null);
return Native.Z3_fixedpoint_get_reason_unknown(Context.nCtx, NativeObject);
}
@ -252,7 +250,7 @@ namespace Microsoft.Z3
/// </summary>
public void SetPredicateRepresentation(FuncDecl f, Symbol[] kinds)
{
Contract.Requires(f != null);
Debug.Assert(f != null);
Native.Z3_fixedpoint_set_predicate_representation(Context.nCtx, NativeObject,
f.NativeObject, AST.ArrayLength(kinds), Symbol.ArrayToNative(kinds));
@ -276,7 +274,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<BoolExpr[]>() != null);
ASTVector av = new ASTVector(Context, Native.Z3_fixedpoint_get_rules(Context.nCtx, NativeObject));
return av.ToBoolExprArray();
@ -290,7 +287,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<BoolExpr[]>() != null);
ASTVector av = new ASTVector(Context, Native.Z3_fixedpoint_get_assertions(Context.nCtx, NativeObject));
return av.ToBoolExprArray();
@ -304,7 +300,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<Statistics>() != null);
return new Statistics(Context, Native.Z3_fixedpoint_get_statistics(Context.nCtx, NativeObject));
}
@ -335,12 +330,12 @@ namespace Microsoft.Z3
internal Fixedpoint(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
internal Fixedpoint(Context ctx)
: base(ctx, Native.Z3_mk_fixedpoint(ctx.nCtx))
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
internal class DecRefQueue : IDecRefQueue

View file

@ -18,14 +18,15 @@ Notes:
--*/
using System;
using System.Diagnostics.Contracts;
using System.Diagnostics;
using System.Linq;
namespace Microsoft.Z3
{
/// <summary>
/// Function declarations.
/// </summary>
[ContractVerification(true)]
public class FuncDecl : AST
{
/// <summary>
@ -108,7 +109,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<Sort[]>() != null);
uint n = DomainSize;
@ -126,7 +126,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<Sort>() != null);
return Sort.Create(Context, Native.Z3_get_range(Context.nCtx, NativeObject));
}
}
@ -146,7 +145,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<Symbol>() != null);
return Symbol.Create(Context, Native.Z3_get_decl_name(Context.nCtx, NativeObject));
}
}
@ -166,7 +164,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<Parameter[]>() != null);
uint num = NumParameters;
Parameter[] res = new Parameter[num];
@ -287,24 +284,33 @@ namespace Microsoft.Z3
internal FuncDecl(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
internal FuncDecl(Context ctx, Symbol name, Sort[] domain, Sort range)
: base(ctx, Native.Z3_mk_func_decl(ctx.nCtx, name.NativeObject, AST.ArrayLength(domain), AST.ArrayToNative(domain), range.NativeObject))
{
Contract.Requires(ctx != null);
Contract.Requires(name != null);
Contract.Requires(range != null);
Debug.Assert(ctx != null);
Debug.Assert(name != null);
Debug.Assert(range != null);
}
internal FuncDecl(Context ctx, string prefix, Sort[] domain, Sort range)
: base(ctx, Native.Z3_mk_fresh_func_decl(ctx.nCtx, prefix, AST.ArrayLength(domain), AST.ArrayToNative(domain), range.NativeObject))
{
Contract.Requires(ctx != null);
Contract.Requires(range != null);
Debug.Assert(ctx != null);
Debug.Assert(range != null);
}
internal FuncDecl(Context ctx, Symbol name, Sort[] domain, Sort range, bool is_rec)
: base(ctx, Native.Z3_mk_rec_func_decl(ctx.nCtx, name.NativeObject, AST.ArrayLength(domain), AST.ArrayToNative(domain), range.NativeObject))
{
Debug.Assert(ctx != null);
Debug.Assert(name != null);
Debug.Assert(range != null);
}
#if DEBUG
internal override void CheckNativeObject(IntPtr obj)
{
@ -335,7 +341,7 @@ namespace Microsoft.Z3
{
get
{
Contract.Requires(args == null || Contract.ForAll(args, a => a != null));
Debug.Assert(args == null || args.All(a => a != null));
return Apply(args);
}
@ -348,7 +354,7 @@ namespace Microsoft.Z3
/// <returns></returns>
public Expr Apply(params Expr[] args)
{
Contract.Requires(args == null || Contract.ForAll(args, a => a != null));
Debug.Assert(args == null || args.All(a => a != null));
Context.CheckContextMatch<Expr>(args);
return Expr.Create(Context, this, args);

View file

@ -17,8 +17,8 @@ Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
@ -26,7 +26,6 @@ namespace Microsoft.Z3
/// A function interpretation is represented as a finite map and an 'else' value.
/// Each entry in the finite map represents the value of a function given a set of arguments.
/// </summary>
[ContractVerification(true)]
public class FuncInterp : Z3Object
{
/// <summary>
@ -42,7 +41,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<Expr>() != null);
return Expr.Create(Context, Native.Z3_func_entry_get_value(Context.nCtx, NativeObject));
}
}
@ -62,8 +60,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<Expr[]>() != null);
Contract.Ensures(Contract.Result<Expr[]>().Length == this.NumArgs);
uint n = NumArgs;
Expr[] res = new Expr[n];
@ -87,7 +83,7 @@ namespace Microsoft.Z3
}
#region Internal
internal Entry(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
internal Entry(Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx != null); }
internal class DecRefQueue : IDecRefQueue
{
@ -133,8 +129,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<Entry[]>() != null);
Contract.Ensures(Contract.ForAll(0, Contract.Result<Entry[]>().Length, j => Contract.Result<Entry[]>()[j] != null));
uint n = NumEntries;
Entry[] res = new Entry[n];
@ -151,7 +145,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<Expr>() != null);
return Expr.Create(Context, Native.Z3_func_interp_get_else(Context.nCtx, NativeObject));
}
@ -194,7 +187,7 @@ namespace Microsoft.Z3
internal FuncInterp(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
internal class DecRefQueue : IDecRefQueue

View file

@ -17,9 +17,9 @@ Notes:
--*/
using System.Diagnostics;
using System;
using System.Runtime.InteropServices;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{

View file

@ -18,7 +18,8 @@ Notes:
--*/
using System;
using System.Diagnostics.Contracts;
using System.Diagnostics;
using System.Linq;
namespace Microsoft.Z3
{
@ -27,7 +28,6 @@ namespace Microsoft.Z3
/// of formulas, that can be solved and/or transformed using
/// tactics and solvers.
/// </summary>
[ContractVerification(true)]
public class Goal : Z3Object
{
/// <summary>
@ -79,13 +79,13 @@ namespace Microsoft.Z3
/// </summary>
public void Assert(params BoolExpr[] constraints)
{
Contract.Requires(constraints != null);
Contract.Requires(Contract.ForAll(constraints, c => c != null));
Debug.Assert(constraints != null);
Debug.Assert(constraints.All(c => c != null));
Context.CheckContextMatch<BoolExpr>(constraints);
foreach (BoolExpr c in constraints)
{
Contract.Assert(c != null); // It was an assume, now made an assert just to be sure we do not regress
Debug.Assert(c != null); // It was an assume, now made an assert just to be sure we do not regress
Native.Z3_goal_assert(Context.nCtx, NativeObject, c.NativeObject);
}
}
@ -140,7 +140,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<BoolExpr[]>() != null);
uint n = Size;
BoolExpr[] res = new BoolExpr[n];
@ -181,7 +180,6 @@ namespace Microsoft.Z3
/// <returns>A model for <c>g</c></returns>
public Model ConvertModel(Model m)
{
Contract.Ensures(Contract.Result<Model>() != null);
if (m != null)
return new Model(Context, Native.Z3_goal_convert_model(Context.nCtx, NativeObject, m.NativeObject));
else
@ -194,7 +192,7 @@ namespace Microsoft.Z3
/// </summary>
public Goal Translate(Context ctx)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
return new Goal(ctx, Native.Z3_goal_translate(Context.nCtx, NativeObject, ctx.nCtx));
}
@ -248,12 +246,12 @@ namespace Microsoft.Z3
}
#region Internal
internal Goal(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
internal Goal(Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx != null); }
internal Goal(Context ctx, bool models, bool unsatCores, bool proofs)
: base(ctx, Native.Z3_mk_goal(ctx.nCtx, (byte)(models ? 1 : 0), (byte)(unsatCores ? 1 : 0), (byte)(proofs ? 1 : 0)))
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
internal class DecRefQueue : IDecRefQueue

View file

@ -17,26 +17,24 @@ Notes:
--*/
using System.Diagnostics;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// DecRefQueue interface
/// </summary>
[ContractClass(typeof(DecRefQueueContracts))]
public abstract class IDecRefQueue
{
#region Object invariant
[ContractInvariantMethod]
private void ObjectInvariant()
{
Contract.Invariant(this.m_queue != null);
Debug.Assert(this.m_queue != null);
}
#endregion
@ -61,7 +59,7 @@ namespace Microsoft.Z3
internal void IncAndClear(Context ctx, IntPtr o)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
IncRef(ctx, o);
if (m_queue.Count >= m_move_limit) Clear(ctx);
@ -79,7 +77,7 @@ namespace Microsoft.Z3
internal void Clear(Context ctx)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
lock (m_lock)
{
@ -90,17 +88,16 @@ namespace Microsoft.Z3
}
}
[ContractClassFor(typeof(IDecRefQueue))]
abstract class DecRefQueueContracts : IDecRefQueue
{
internal override void IncRef(Context ctx, IntPtr obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
internal override void DecRef(Context ctx, IntPtr obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
}
}

View file

@ -16,12 +16,12 @@ Author:
Notes:
--*/
using System.Diagnostics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
@ -35,7 +35,7 @@ namespace Microsoft.Z3
internal IntExpr(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
#endregion
}

View file

@ -16,8 +16,8 @@ Author:
Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
#if !FRAMEWORK_LT_4
using System.Numerics;
@ -28,7 +28,6 @@ namespace Microsoft.Z3
/// <summary>
/// Integer Numerals
/// </summary>
[ContractVerification(true)]
public class IntNum : IntExpr
{
@ -36,7 +35,7 @@ namespace Microsoft.Z3
internal IntNum(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
#endregion

View file

@ -17,8 +17,8 @@ Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
@ -31,12 +31,12 @@ namespace Microsoft.Z3
internal IntSort(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
internal IntSort(Context ctx)
: base(ctx, Native.Z3_mk_int_sort(ctx.nCtx))
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
#endregion
}

View file

@ -18,15 +18,14 @@ Notes:
--*/
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// Numbered symbols
/// </summary>
[ContractVerification(true)]
public class IntSymbol : Symbol
{
/// <summary>
@ -47,12 +46,12 @@ namespace Microsoft.Z3
internal IntSymbol(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
internal IntSymbol(Context ctx, int i)
: base(ctx, Native.Z3_mk_int_symbol(ctx.nCtx, i))
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
#if DEBUG

View file

@ -18,14 +18,14 @@ Notes:
--*/
using System;
using System.Diagnostics.Contracts;
using System.Diagnostics;
using System.Linq;
namespace Microsoft.Z3
{
/// <summary>
/// Lambda expressions.
/// </summary>
[ContractVerification(true)]
public class Lambda : ArrayExpr
{
/// <summary>
@ -43,7 +43,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<Symbol[]>() != null);
uint n = NumBound;
Symbol[] res = new Symbol[n];
@ -60,7 +59,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<Sort[]>() != null);
uint n = NumBound;
Sort[] res = new Sort[n];
@ -77,7 +75,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<BoolExpr>() != null);
return new BoolExpr(Context, Native.Z3_get_quantifier_body(Context.nCtx, NativeObject));
}
@ -94,17 +91,16 @@ namespace Microsoft.Z3
}
#region Internal
[ContractVerification(false)] // F: Clousot ForAll decompilation gets confused below. Setting verification off until I fixed the bug
internal Lambda(Context ctx, Sort[] sorts, Symbol[] names, Expr body)
: base(ctx, IntPtr.Zero)
{
Contract.Requires(ctx != null);
Contract.Requires(sorts != null);
Contract.Requires(names != null);
Contract.Requires(body != null);
Contract.Requires(sorts.Length == names.Length);
Contract.Requires(Contract.ForAll(sorts, s => s != null));
Contract.Requires(Contract.ForAll(names, n => n != null));
Debug.Assert(ctx != null);
Debug.Assert(sorts != null);
Debug.Assert(names != null);
Debug.Assert(body != null);
Debug.Assert(sorts.Length == names.Length);
Debug.Assert(sorts.All(s => s != null));
Debug.Assert(names.All(n => n != null));
Context.CheckContextMatch<Sort>(sorts);
Context.CheckContextMatch<Symbol>(names);
Context.CheckContextMatch(body);
@ -119,14 +115,13 @@ namespace Microsoft.Z3
}
[ContractVerification(false)] // F: Clousot ForAll decompilation gets confused below. Setting verification off until I fixed the bug
internal Lambda(Context ctx, Expr[] bound, Expr body)
: base(ctx, IntPtr.Zero)
{
Contract.Requires(ctx != null);
Contract.Requires(body != null);
Debug.Assert(ctx != null);
Debug.Assert(body != null);
Contract.Requires(bound != null && bound.Length > 0 && Contract.ForAll(bound, n => n != null));
Debug.Assert(bound != null && bound.Length > 0 && bound.All(n => n != null));
Context.CheckContextMatch<Expr>(bound);
Context.CheckContextMatch(body);
@ -137,7 +132,7 @@ namespace Microsoft.Z3
}
internal Lambda(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
internal Lambda(Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx != null); }
#if DEBUG
internal override void CheckNativeObject(IntPtr obj)

View file

@ -17,15 +17,14 @@ Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// List sorts.
/// </summary>
[ContractVerification(true)]
public class ListSort : Sort
{
/// <summary>
@ -35,7 +34,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<FuncDecl>() != null);
return new FuncDecl(Context, Native.Z3_get_datatype_sort_constructor(Context.nCtx, NativeObject, 0));
}
}
@ -47,7 +45,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<Expr>() != null);
return Context.MkApp(NilDecl);
}
}
@ -59,7 +56,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<FuncDecl>() != null);
return new FuncDecl(Context, Native.Z3_get_datatype_sort_recognizer(Context.nCtx, NativeObject, 0));
}
}
@ -71,7 +67,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<FuncDecl>() != null);
return new FuncDecl(Context, Native.Z3_get_datatype_sort_constructor(Context.nCtx, NativeObject, 1));
}
}
@ -84,7 +79,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<FuncDecl>() != null);
return new FuncDecl(Context, Native.Z3_get_datatype_sort_recognizer(Context.nCtx, NativeObject, 1));
}
}
@ -96,7 +90,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<FuncDecl>() != null);
return new FuncDecl(Context, Native.Z3_get_datatype_sort_constructor_accessor(Context.nCtx, NativeObject, 1, 0));
}
}
@ -108,7 +101,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<FuncDecl>() != null);
return new FuncDecl(Context, Native.Z3_get_datatype_sort_constructor_accessor(Context.nCtx, NativeObject, 1, 1));
}
}
@ -117,9 +109,9 @@ namespace Microsoft.Z3
internal ListSort(Context ctx, Symbol name, Sort elemSort)
: base(ctx, IntPtr.Zero)
{
Contract.Requires(ctx != null);
Contract.Requires(name != null);
Contract.Requires(elemSort != null);
Debug.Assert(ctx != null);
Debug.Assert(name != null);
Debug.Assert(elemSort != null);
IntPtr inil = IntPtr.Zero, iisnil = IntPtr.Zero,
icons = IntPtr.Zero, iiscons = IntPtr.Zero,

View file

@ -17,8 +17,8 @@ Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
@ -29,7 +29,6 @@ namespace Microsoft.Z3
/// Note that this is a global, static log and if multiple Context
/// objects are created, it logs the interaction with all of them.
/// </remarks>
[ContractVerification(true)]
public static class Log
{
private static bool m_is_open = false;
@ -59,7 +58,7 @@ namespace Microsoft.Z3
/// </summary>
public static void Append(string s)
{
Contract.Requires(isOpen());
Debug.Assert(isOpen());
if (!m_is_open)
throw new Z3Exception("Log cannot be closed.");
@ -70,7 +69,6 @@ namespace Microsoft.Z3
/// Checks whether the interaction log is opened.
/// </summary>
/// <returns>True if the interaction log is open, false otherwise.</returns>
[Pure]
public static bool isOpen()
{
return m_is_open;

View file

@ -5,6 +5,7 @@
<PackageId>Microsoft.Z3</PackageId>
<AssemblyName>Microsoft.Z3</AssemblyName>
<RootNamespace>Microsoft.Z3</RootNamespace>
<Title>Z3 .NET Interface</Title>
<AssemblyTitle>Z3 .NET Interface</AssemblyTitle>
@ -29,6 +30,159 @@
<PackageVersion>${DOTNET_PACKAGE_VERSION}</PackageVersion>
</PropertyGroup>
<!-- Code contract & signing properties -->
<PropertyGroup>
<SignAssembly>false</SignAssembly>
<AssemblyOriginatorKeyFile> </AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<CodeContractsEnableRuntimeChecking>False</CodeContractsEnableRuntimeChecking>
<CodeContractsRuntimeOnlyPublicSurface>False</CodeContractsRuntimeOnlyPublicSurface>
<CodeContractsRuntimeThrowOnFailure>True</CodeContractsRuntimeThrowOnFailure>
<CodeContractsRuntimeCallSiteRequires>False</CodeContractsRuntimeCallSiteRequires>
<CodeContractsRuntimeSkipQuantifiers>False</CodeContractsRuntimeSkipQuantifiers>
<CodeContractsRunCodeAnalysis>True</CodeContractsRunCodeAnalysis>
<CodeContractsNonNullObligations>False</CodeContractsNonNullObligations>
<CodeContractsBoundsObligations>True</CodeContractsBoundsObligations>
<CodeContractsArithmeticObligations>True</CodeContractsArithmeticObligations>
<CodeContractsEnumObligations>False</CodeContractsEnumObligations>
<CodeContractsPointerObligations>False</CodeContractsPointerObligations>
<CodeContractsRedundantAssumptions>False</CodeContractsRedundantAssumptions>
<CodeContractsInferRequires>True</CodeContractsInferRequires>
<CodeContractsInferEnsures>False</CodeContractsInferEnsures>
<CodeContractsInferObjectInvariants>False</CodeContractsInferObjectInvariants>
<CodeContractsSuggestAssumptions>False</CodeContractsSuggestAssumptions>
<CodeContractsSuggestRequires>True</CodeContractsSuggestRequires>
<CodeContractsSuggestEnsures>False</CodeContractsSuggestEnsures>
<CodeContractsSuggestObjectInvariants>False</CodeContractsSuggestObjectInvariants>
<CodeContractsDisjunctiveRequires>True</CodeContractsDisjunctiveRequires>
<CodeContractsRunInBackground>True</CodeContractsRunInBackground>
<CodeContractsShowSquigglies>True</CodeContractsShowSquigglies>
<CodeContractsUseBaseLine>False</CodeContractsUseBaseLine>
<CodeContractsEmitXMLDocs>False</CodeContractsEmitXMLDocs>
<CodeContractsCustomRewriterAssembly />
<CodeContractsCustomRewriterClass />
<CodeContractsLibPaths />
<CodeContractsExtraRewriteOptions />
<CodeContractsExtraAnalysisOptions />
<CodeContractsBaseLineFile />
<CodeContractsCacheAnalysisResults>True</CodeContractsCacheAnalysisResults>
<CodeContractsRuntimeCheckingLevel>Full</CodeContractsRuntimeCheckingLevel>
<CodeContractsReferenceAssembly>%28none%29</CodeContractsReferenceAssembly>
<CodeContractsAnalysisWarningLevel>2</CodeContractsAnalysisWarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
<CodeContractsEnableRuntimeChecking>True</CodeContractsEnableRuntimeChecking>
<CodeContractsRuntimeOnlyPublicSurface>False</CodeContractsRuntimeOnlyPublicSurface>
<CodeContractsRuntimeThrowOnFailure>True</CodeContractsRuntimeThrowOnFailure>
<CodeContractsRuntimeCallSiteRequires>False</CodeContractsRuntimeCallSiteRequires>
<CodeContractsRuntimeSkipQuantifiers>False</CodeContractsRuntimeSkipQuantifiers>
<CodeContractsRunCodeAnalysis>False</CodeContractsRunCodeAnalysis>
<CodeContractsNonNullObligations>False</CodeContractsNonNullObligations>
<CodeContractsBoundsObligations>False</CodeContractsBoundsObligations>
<CodeContractsArithmeticObligations>False</CodeContractsArithmeticObligations>
<CodeContractsEnumObligations>False</CodeContractsEnumObligations>
<CodeContractsPointerObligations>False</CodeContractsPointerObligations>
<CodeContractsRedundantAssumptions>False</CodeContractsRedundantAssumptions>
<CodeContractsInferRequires>False</CodeContractsInferRequires>
<CodeContractsInferEnsures>False</CodeContractsInferEnsures>
<CodeContractsInferObjectInvariants>False</CodeContractsInferObjectInvariants>
<CodeContractsSuggestAssumptions>False</CodeContractsSuggestAssumptions>
<CodeContractsSuggestRequires>True</CodeContractsSuggestRequires>
<CodeContractsSuggestEnsures>False</CodeContractsSuggestEnsures>
<CodeContractsSuggestObjectInvariants>False</CodeContractsSuggestObjectInvariants>
<CodeContractsRunInBackground>True</CodeContractsRunInBackground>
<CodeContractsShowSquigglies>False</CodeContractsShowSquigglies>
<CodeContractsUseBaseLine>False</CodeContractsUseBaseLine>
<CodeContractsEmitXMLDocs>False</CodeContractsEmitXMLDocs>
<CodeContractsCustomRewriterAssembly />
<CodeContractsCustomRewriterClass />
<CodeContractsLibPaths />
<CodeContractsExtraRewriteOptions />
<CodeContractsExtraAnalysisOptions />
<CodeContractsBaseLineFile />
<CodeContractsCacheAnalysisResults>False</CodeContractsCacheAnalysisResults>
<CodeContractsRuntimeCheckingLevel>Full</CodeContractsRuntimeCheckingLevel>
<CodeContractsReferenceAssembly>%28none%29</CodeContractsReferenceAssembly>
<CodeContractsAnalysisWarningLevel>0</CodeContractsAnalysisWarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
<CodeContractsEnableRuntimeChecking>True</CodeContractsEnableRuntimeChecking>
<CodeContractsRuntimeOnlyPublicSurface>False</CodeContractsRuntimeOnlyPublicSurface>
<CodeContractsRuntimeThrowOnFailure>True</CodeContractsRuntimeThrowOnFailure>
<CodeContractsRuntimeCallSiteRequires>False</CodeContractsRuntimeCallSiteRequires>
<CodeContractsRuntimeSkipQuantifiers>False</CodeContractsRuntimeSkipQuantifiers>
<CodeContractsRunCodeAnalysis>True</CodeContractsRunCodeAnalysis>
<CodeContractsNonNullObligations>True</CodeContractsNonNullObligations>
<CodeContractsBoundsObligations>True</CodeContractsBoundsObligations>
<CodeContractsArithmeticObligations>False</CodeContractsArithmeticObligations>
<CodeContractsEnumObligations>False</CodeContractsEnumObligations>
<CodeContractsPointerObligations>False</CodeContractsPointerObligations>
<CodeContractsRedundantAssumptions>True</CodeContractsRedundantAssumptions>
<CodeContractsInferRequires>True</CodeContractsInferRequires>
<CodeContractsInferEnsures>False</CodeContractsInferEnsures>
<CodeContractsInferObjectInvariants>False</CodeContractsInferObjectInvariants>
<CodeContractsSuggestAssumptions>False</CodeContractsSuggestAssumptions>
<CodeContractsSuggestRequires>True</CodeContractsSuggestRequires>
<CodeContractsSuggestEnsures>False</CodeContractsSuggestEnsures>
<CodeContractsSuggestObjectInvariants>False</CodeContractsSuggestObjectInvariants>
<CodeContractsRunInBackground>True</CodeContractsRunInBackground>
<CodeContractsShowSquigglies>True</CodeContractsShowSquigglies>
<CodeContractsUseBaseLine>False</CodeContractsUseBaseLine>
<CodeContractsEmitXMLDocs>False</CodeContractsEmitXMLDocs>
<CodeContractsCustomRewriterAssembly />
<CodeContractsCustomRewriterClass />
<CodeContractsLibPaths />
<CodeContractsExtraRewriteOptions />
<CodeContractsExtraAnalysisOptions>-repro</CodeContractsExtraAnalysisOptions>
<CodeContractsBaseLineFile />
<CodeContractsCacheAnalysisResults>True</CodeContractsCacheAnalysisResults>
<CodeContractsRuntimeCheckingLevel>Full</CodeContractsRuntimeCheckingLevel>
<CodeContractsReferenceAssembly>%28none%29</CodeContractsReferenceAssembly>
<CodeContractsAnalysisWarningLevel>2</CodeContractsAnalysisWarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release_delaysign'">
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSetDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisRuleDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
<DefineConstants>DELAYSIGN</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'external' ">
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSetDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisRuleDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)' == 'x86'">
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
</PropertyGroup>
<!-- Build properties -->
<PropertyGroup>
<!-- Add net40;net35 only if the appropriate SDKs are installed. -->
@ -39,6 +193,8 @@
<NoWarn>1701,1702</NoWarn>
<Warn>4</Warn>
<DefineConstants Condition="'$(TargetFramework)'=='net35'">FRAMEWORK_LT_4</DefineConstants>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<DocumentationFile>$(OutputPath)\Microsoft.Z3.xml</DocumentationFile>
</PropertyGroup>
<!-- Compilation items -->
@ -56,9 +212,10 @@ ${Z3_DOTNET_COMPILE_ITEMS}
</Content>
</ItemGroup>
<!-- Native binaries -->
<ItemGroup>
<!--TODO detect if we're building x86.-->
<!-- TODO we may want to pack x64 and x86 native assemblies into a single nupkg -->
<!-- Native binaries x64 -->
<ItemGroup Condition="'$(Platform)' == 'x64'">
<Content Include="${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/$(Configuration)/libz3.dll" Condition="Exists('${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/$(Configuration)/libz3.dll')">
<PackagePath>runtimes\win-x64\native</PackagePath>
</Content>
@ -67,6 +224,17 @@ ${Z3_DOTNET_COMPILE_ITEMS}
</Content>
</ItemGroup>
<!-- Native binaries for x86, note the platform condition is set to "AnyCPU" -->
<ItemGroup Condition="'$(Platform)' == 'AnyCPU'">
<Content Include="${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/$(Configuration)/libz3.dll" Condition="Exists('${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/$(Configuration)/libz3.dll')">
<PackagePath>runtimes\win-x86\native</PackagePath>
</Content>
<Content Include="${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libz3.so" Condition="Exists('${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libz3.so')">
<PackagePath>runtimes\linux-x86\native</PackagePath>
</Content>
</ItemGroup>
<!-- NuGet package references -->
<ItemGroup Condition="'$(TargetFramework)'=='net35'">
<PackageReference Include="Code.Contract" Version="1.0.0"/>

View file

@ -18,7 +18,7 @@ Notes:
--*/
using System;
using System.Diagnostics.Contracts;
using System.Diagnostics;
using System.Collections.Generic;
namespace Microsoft.Z3
@ -26,7 +26,6 @@ namespace Microsoft.Z3
/// <summary>
/// A Model contains interpretations (assignments) of constants and functions.
/// </summary>
[ContractVerification(true)]
public class Model : Z3Object
{
/// <summary>
@ -36,7 +35,7 @@ namespace Microsoft.Z3
/// <returns>An expression if the constant has an interpretation in the model, null otherwise.</returns>
public Expr ConstInterp(Expr a)
{
Contract.Requires(a != null);
Debug.Assert(a != null);
Context.CheckContextMatch(a);
return ConstInterp(a.FuncDecl);
@ -49,7 +48,7 @@ namespace Microsoft.Z3
/// <returns>An expression if the function has an interpretation in the model, null otherwise.</returns>
public Expr ConstInterp(FuncDecl f)
{
Contract.Requires(f != null);
Debug.Assert(f != null);
Context.CheckContextMatch(f);
if (f.Arity != 0 ||
@ -70,7 +69,7 @@ namespace Microsoft.Z3
/// <returns>A FunctionInterpretation if the function has an interpretation in the model, null otherwise.</returns>
public FuncInterp FuncInterp(FuncDecl f)
{
Contract.Requires(f != null);
Debug.Assert(f != null);
Context.CheckContextMatch(f);
@ -122,7 +121,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<FuncDecl[]>() != null);
uint n = NumConsts;
FuncDecl[] res = new FuncDecl[n];
@ -165,7 +163,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<FuncDecl[]>() != null);
uint n = NumFuncs;
FuncDecl[] res = new FuncDecl[n];
@ -182,7 +179,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<FuncDecl[]>() != null);
uint nFuncs = NumFuncs;
uint nConsts = NumConsts;
@ -223,8 +219,7 @@ namespace Microsoft.Z3
/// <returns>The evaluation of <paramref name="t"/> in the model.</returns>
public Expr Eval(Expr t, bool completion = false)
{
Contract.Requires(t != null);
Contract.Ensures(Contract.Result<Expr>() != null);
Debug.Assert(t != null);
IntPtr v = IntPtr.Zero;
if (Native.Z3_model_eval(Context.nCtx, NativeObject, t.NativeObject, (byte)(completion ? 1 : 0), ref v) == (byte)0)
@ -238,12 +233,19 @@ namespace Microsoft.Z3
/// </summary>
public Expr Evaluate(Expr t, bool completion = false)
{
Contract.Requires(t != null);
Contract.Ensures(Contract.Result<Expr>() != null);
Debug.Assert(t != null);
return Eval(t, completion);
}
/// <summary>
/// Evaluate expression to a double, assuming it is a numeral already.
/// </summary>
public double Double(Expr t) {
var r = Eval(t, true);
return Native.Z3_get_numeral_double(Context.nCtx, r.NativeObject);
}
/// <summary>
/// The number of uninterpreted sorts that the model has an interpretation for.
/// </summary>
@ -263,7 +265,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<Sort[]>() != null);
uint n = NumSorts;
Sort[] res = new Sort[n];
@ -281,8 +282,7 @@ namespace Microsoft.Z3
/// <returns>An array of expressions, where each is an element of the universe of <paramref name="s"/></returns>
public Expr[] SortUniverse(Sort s)
{
Contract.Requires(s != null);
Contract.Ensures(Contract.Result<Expr[]>() != null);
Debug.Assert(s != null);
ASTVector av = new ASTVector(Context, Native.Z3_model_get_sort_universe(Context.nCtx, NativeObject, s.NativeObject));
return av.ToExprArray();
@ -301,7 +301,7 @@ namespace Microsoft.Z3
internal Model(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
internal class DecRefQueue : IDecRefQueue

View file

@ -19,14 +19,14 @@ Notes:
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Diagnostics;
using System.Linq;
namespace Microsoft.Z3
{
/// <summary>
/// Object for managing optimizization context
/// Object for managing optimization context
/// </summary>
[ContractVerification(true)]
public class Optimize : Z3Object
{
/// <summary>
@ -36,7 +36,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<string>() != null);
return Native.Z3_optimize_get_help(Context.nCtx, NativeObject);
}
}
@ -48,7 +47,7 @@ namespace Microsoft.Z3
{
set
{
Contract.Requires(value != null);
Debug.Assert(value != null);
Context.CheckContextMatch(value);
Native.Z3_optimize_set_params(Context.nCtx, NativeObject, value.NativeObject);
}
@ -99,8 +98,8 @@ namespace Microsoft.Z3
/// </summary>
private void AddConstraints(IEnumerable<BoolExpr> constraints)
{
Contract.Requires(constraints != null);
Contract.Requires(Contract.ForAll(constraints, c => c != null));
Debug.Assert(constraints != null);
Debug.Assert(constraints.All(c => c != null));
Context.CheckContextMatch(constraints);
foreach (BoolExpr a in constraints)
@ -183,9 +182,9 @@ namespace Microsoft.Z3
/// don't use strict inequalities) meets the objectives.
/// </summary>
///
public Status Check()
public Status Check(params Expr[] assumptions)
{
Z3_lbool r = (Z3_lbool)Native.Z3_optimize_check(Context.nCtx, NativeObject);
Z3_lbool r = (Z3_lbool)Native.Z3_optimize_check(Context.nCtx, NativeObject, (uint)assumptions.Length, AST.ArrayToNative(assumptions));
switch (r)
{
case Z3_lbool.Z3_L_TRUE:
@ -236,6 +235,24 @@ namespace Microsoft.Z3
}
}
/// <summary>
/// The unsat core of the last <c>Check</c>.
/// </summary>
/// <remarks>
/// The unsat core is a subset of <c>assumptions</c>
/// The result is empty if <c>Check</c> was not invoked before,
/// if its results was not <c>UNSATISFIABLE</c>, or if core production is disabled.
/// </remarks>
public BoolExpr[] UnsatCore
{
get
{
ASTVector core = new ASTVector(Context, Native.Z3_optimize_get_unsat_core(Context.nCtx, NativeObject));
return core.ToBoolExprArray();
}
}
/// <summary>
/// Declare an arithmetical maximization objective.
/// Return a handle to the objective. The handle is used as
@ -300,7 +317,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<string>() != null);
return Native.Z3_optimize_get_reason_unknown(Context.nCtx, NativeObject);
}
}
@ -338,7 +354,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<BoolExpr[]>() != null);
ASTVector assertions = new ASTVector(Context, Native.Z3_optimize_get_assertions(Context.nCtx, NativeObject));
return assertions.ToBoolExprArray();
@ -352,7 +367,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<Expr[]>() != null);
ASTVector objectives = new ASTVector(Context, Native.Z3_optimize_get_objectives(Context.nCtx, NativeObject));
return objectives.ToExprArray();
@ -367,7 +381,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<Statistics>() != null);
return new Statistics(Context, Native.Z3_optimize_get_statistics(Context.nCtx, NativeObject));
}
@ -378,12 +391,12 @@ namespace Microsoft.Z3
internal Optimize(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
internal Optimize(Context ctx)
: base(ctx, Native.Z3_mk_optimize(ctx.nCtx))
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
internal class DecRefQueue : IDecRefQueue

View file

@ -17,15 +17,14 @@ Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// A ParamDescrs describes a set of parameters.
/// </summary>
[ContractVerification(true)]
public class ParamDescrs : Z3Object
{
/// <summary>
@ -33,7 +32,7 @@ namespace Microsoft.Z3
/// </summary>
public void Validate(Params p)
{
Contract.Requires(p != null);
Debug.Assert(p != null);
Native.Z3_params_validate(Context.nCtx, p.NativeObject, NativeObject);
}
@ -42,7 +41,7 @@ namespace Microsoft.Z3
/// </summary>
public Z3_param_kind GetKind(Symbol name)
{
Contract.Requires(name != null);
Debug.Assert(name != null);
return (Z3_param_kind)Native.Z3_param_descrs_get_kind(Context.nCtx, NativeObject, name.NativeObject);
}
@ -51,7 +50,7 @@ namespace Microsoft.Z3
/// </summary>
public string GetDocumentation(Symbol name)
{
Contract.Requires(name != null);
Debug.Assert(name != null);
return Native.Z3_param_descrs_get_documentation(Context.nCtx, NativeObject, name.NativeObject);
}
@ -91,7 +90,7 @@ namespace Microsoft.Z3
internal ParamDescrs(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
internal class DecRefQueue : IDecRefQueue

View file

@ -17,15 +17,14 @@ Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// A Params objects represents a configuration in the form of Symbol/value pairs.
/// </summary>
[ContractVerification(true)]
public class Params : Z3Object
{
/// <summary>
@ -33,7 +32,7 @@ namespace Microsoft.Z3
/// </summary>
public Params Add(Symbol name, bool value)
{
Contract.Requires(name != null);
Debug.Assert(name != null);
Native.Z3_params_set_bool(Context.nCtx, NativeObject, name.NativeObject, (byte)(value ? 1 : 0));
return this;
@ -44,7 +43,7 @@ namespace Microsoft.Z3
/// </summary>
public Params Add(Symbol name, uint value)
{
Contract.Requires(name != null);
Debug.Assert(name != null);
Native.Z3_params_set_uint(Context.nCtx, NativeObject, name.NativeObject, value);
return this;
@ -55,7 +54,7 @@ namespace Microsoft.Z3
/// </summary>
public Params Add(Symbol name, double value)
{
Contract.Requires(name != null);
Debug.Assert(name != null);
Native.Z3_params_set_double(Context.nCtx, NativeObject, name.NativeObject, value);
return this;
@ -66,7 +65,7 @@ namespace Microsoft.Z3
/// </summary>
public Params Add(Symbol name, string value)
{
Contract.Requires(value != null);
Debug.Assert(value != null);
Native.Z3_params_set_symbol(Context.nCtx, NativeObject, name.NativeObject, Context.MkSymbol(value).NativeObject);
return this;
@ -77,8 +76,8 @@ namespace Microsoft.Z3
/// </summary>
public Params Add(Symbol name, Symbol value)
{
Contract.Requires(name != null);
Contract.Requires(value != null);
Debug.Assert(name != null);
Debug.Assert(value != null);
Native.Z3_params_set_symbol(Context.nCtx, NativeObject, name.NativeObject, value.NativeObject);
return this;
@ -117,7 +116,7 @@ namespace Microsoft.Z3
/// </summary>
public Params Add(string name, Symbol value)
{
Contract.Requires(value != null);
Debug.Assert(value != null);
Native.Z3_params_set_symbol(Context.nCtx, NativeObject, Context.MkSymbol(name).NativeObject, value.NativeObject);
return this;
@ -128,8 +127,8 @@ namespace Microsoft.Z3
/// </summary>
public Params Add(string name, string value)
{
Contract.Requires(name != null);
Contract.Requires(value != null);
Debug.Assert(name != null);
Debug.Assert(value != null);
Native.Z3_params_set_symbol(Context.nCtx, NativeObject, Context.MkSymbol(name).NativeObject, Context.MkSymbol(value).NativeObject);
return this;
@ -147,7 +146,7 @@ namespace Microsoft.Z3
internal Params(Context ctx)
: base(ctx, Native.Z3_mk_params(ctx.nCtx))
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
internal class DecRefQueue : IDecRefQueue

View file

@ -17,9 +17,9 @@ Notes:
--*/
using System.Diagnostics;
using System;
using System.Runtime.InteropServices;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
@ -28,7 +28,6 @@ namespace Microsoft.Z3
/// non-empty. If the list comprises of more than one term, it is
/// also called a multi-pattern.
/// </summary>
[ContractVerification(true)]
public class Pattern : AST
{
/// <summary>
@ -46,7 +45,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<Expr[]>() != null);
uint n = NumTerms;
Expr[] res = new Expr[n];
@ -68,7 +66,7 @@ namespace Microsoft.Z3
internal Pattern(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
#endregion
}

View file

@ -17,9 +17,9 @@ Notes:
--*/
using System.Diagnostics;
using System;
using System.Runtime.InteropServices;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
@ -30,7 +30,6 @@ namespace Microsoft.Z3
/// and <c>Context.ProbeNames</c>.
/// It may also be obtained using the command <c>(help-tactic)</c> in the SMT 2.0 front-end.
/// </summary>
[ContractVerification(true)]
public class Probe : Z3Object
{
/// <summary>
@ -40,7 +39,7 @@ namespace Microsoft.Z3
/// "Boolean" probes return 0.0 for false, and a value different from 0.0 for true.</returns>
public double Apply(Goal g)
{
Contract.Requires(g != null);
Debug.Assert(g != null);
Context.CheckContextMatch(g);
return Native.Z3_probe_apply(Context.nCtx, NativeObject, g.NativeObject);
@ -53,7 +52,7 @@ namespace Microsoft.Z3
{
get
{
Contract.Requires(g != null);
Debug.Assert(g != null);
return Apply(g);
}
@ -63,12 +62,12 @@ namespace Microsoft.Z3
internal Probe(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
internal Probe(Context ctx, string name)
: base(ctx, Native.Z3_mk_probe(ctx.nCtx, name))
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
internal class DecRefQueue : IDecRefQueue

View file

@ -18,14 +18,14 @@ Notes:
--*/
using System;
using System.Diagnostics.Contracts;
using System.Diagnostics;
using System.Linq;
namespace Microsoft.Z3
{
/// <summary>
/// Quantifier expressions.
/// </summary>
[ContractVerification(true)]
public class Quantifier : BoolExpr
{
/// <summary>
@ -67,7 +67,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<Pattern[]>() != null);
uint n = NumPatterns;
Pattern[] res = new Pattern[n];
@ -92,7 +91,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<Pattern[]>() != null);
uint n = NumNoPatterns;
Pattern[] res = new Pattern[n];
@ -117,7 +115,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<Symbol[]>() != null);
uint n = NumBound;
Symbol[] res = new Symbol[n];
@ -134,7 +131,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<Sort[]>() != null);
uint n = NumBound;
Sort[] res = new Sort[n];
@ -151,7 +147,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<BoolExpr>() != null);
return new BoolExpr(Context, Native.Z3_get_quantifier_body(Context.nCtx, NativeObject));
}
@ -168,19 +163,18 @@ namespace Microsoft.Z3
}
#region Internal
[ContractVerification(false)] // F: Clousot ForAll decompilation gets confused below. Setting verification off until I fixed the bug
internal Quantifier(Context ctx, bool isForall, Sort[] sorts, Symbol[] names, Expr body, uint weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null, Symbol quantifierID = null, Symbol skolemID = null)
: base(ctx, IntPtr.Zero)
{
Contract.Requires(ctx != null);
Contract.Requires(sorts != null);
Contract.Requires(names != null);
Contract.Requires(body != null);
Contract.Requires(sorts.Length == names.Length);
Contract.Requires(Contract.ForAll(sorts, s => s != null));
Contract.Requires(Contract.ForAll(names, n => n != null));
Contract.Requires(patterns == null || Contract.ForAll(patterns, p => p != null));
Contract.Requires(noPatterns == null || Contract.ForAll(noPatterns, np => np != null));
Debug.Assert(ctx != null);
Debug.Assert(sorts != null);
Debug.Assert(names != null);
Debug.Assert(body != null);
Debug.Assert(sorts.Length == names.Length);
Debug.Assert(sorts.All(s => s != null));
Debug.Assert(names.All(n => n != null));
Debug.Assert(patterns == null || patterns.All(p => p != null));
Debug.Assert(noPatterns == null || noPatterns.All(np => np != null));
Context.CheckContextMatch<Pattern>(patterns);
Context.CheckContextMatch<Expr>(noPatterns);
@ -211,16 +205,15 @@ namespace Microsoft.Z3
}
}
[ContractVerification(false)] // F: Clousot ForAll decompilation gets confused below. Setting verification off until I fixed the bug
internal Quantifier(Context ctx, bool isForall, Expr[] bound, Expr body, uint weight = 1, Pattern[] patterns = null, Expr[] noPatterns = null, Symbol quantifierID = null, Symbol skolemID = null)
: base(ctx, IntPtr.Zero)
{
Contract.Requires(ctx != null);
Contract.Requires(body != null);
Debug.Assert(ctx != null);
Debug.Assert(body != null);
Contract.Requires(patterns == null || Contract.ForAll(patterns, p => p != null));
Contract.Requires(noPatterns == null || Contract.ForAll(noPatterns, np => np != null));
Contract.Requires(bound == null || Contract.ForAll(bound, n => n != null));
Debug.Assert(patterns == null || patterns.All(p => p != null));
Debug.Assert(noPatterns == null || noPatterns.All(np => np != null));
Debug.Assert(bound == null || bound.All(n => n != null));
Context.CheckContextMatch<Expr>(noPatterns);
Context.CheckContextMatch<Pattern>(patterns);
@ -246,7 +239,7 @@ namespace Microsoft.Z3
}
internal Quantifier(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
internal Quantifier(Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx != null); }
#if DEBUG
internal override void CheckNativeObject(IntPtr obj)

View file

@ -16,8 +16,8 @@ Author:
Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
#if !FRAMEWORK_LT_4
using System.Numerics;
@ -28,7 +28,6 @@ namespace Microsoft.Z3
/// <summary>
/// Rational Numerals
/// </summary>
[ContractVerification(true)]
public class RatNum : RealExpr
{
/// <summary>
@ -38,7 +37,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<IntNum>() != null);
return new IntNum(Context, Native.Z3_get_numerator(Context.nCtx, NativeObject));
}
@ -51,7 +49,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<IntNum>() != null);
return new IntNum(Context, Native.Z3_get_denominator(Context.nCtx, NativeObject));
}
@ -92,6 +89,14 @@ namespace Microsoft.Z3
return Native.Z3_get_numeral_decimal_string(Context.nCtx, NativeObject, precision);
}
/// <summary>
/// Returns a double representing the value.
/// </summary>
public double Double
{
get { return Native.Z3_get_numeral_double(Context.nCtx, NativeObject); }
}
/// <summary>
/// Returns a string representation of the numeral.
/// </summary>
@ -104,7 +109,7 @@ namespace Microsoft.Z3
internal RatNum(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
#endregion
}

View file

@ -16,12 +16,12 @@ Author:
Notes:
--*/
using System.Diagnostics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
@ -35,7 +35,7 @@ namespace Microsoft.Z3
internal ReExpr(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
#endregion
}

View file

@ -17,8 +17,8 @@ Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
@ -31,12 +31,12 @@ namespace Microsoft.Z3
internal ReSort(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
internal ReSort(Context ctx)
: base(ctx, Native.Z3_mk_int_sort(ctx.nCtx))
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
#endregion
}

View file

@ -16,12 +16,12 @@ Author:
Notes:
--*/
using System.Diagnostics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
@ -35,7 +35,7 @@ namespace Microsoft.Z3
internal RealExpr(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
#endregion
}

View file

@ -17,8 +17,8 @@ Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
@ -31,12 +31,12 @@ namespace Microsoft.Z3
internal RealSort(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
internal RealSort(Context ctx)
: base(ctx, Native.Z3_mk_real_sort(ctx.nCtx))
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
#endregion
}

View file

@ -17,15 +17,14 @@ Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// Relation sorts.
/// </summary>
[ContractVerification(true)]
public class RelationSort : Sort
{
/// <summary>
@ -43,7 +42,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<Sort[]>() != null);
if (m_columnSorts != null)
return m_columnSorts;
@ -62,7 +60,7 @@ namespace Microsoft.Z3
internal RelationSort(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
#endregion
}

View file

@ -16,12 +16,12 @@ Author:
Notes:
--*/
using System.Diagnostics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
@ -35,7 +35,7 @@ namespace Microsoft.Z3
internal SeqExpr(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
#endregion
}

View file

@ -17,8 +17,8 @@ Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
@ -31,12 +31,12 @@ namespace Microsoft.Z3
internal SeqSort(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
internal SeqSort(Context ctx)
: base(ctx, Native.Z3_mk_int_sort(ctx.nCtx))
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
#endregion
}

View file

@ -17,28 +17,27 @@ Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// Set sorts.
/// </summary>
[ContractVerification(true)]
public class SetSort : Sort
{
#region Internal
internal SetSort(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
internal SetSort(Context ctx, Sort ty)
: base(ctx, Native.Z3_mk_set_sort(ctx.nCtx, ty.NativeObject))
{
Contract.Requires(ctx != null);
Contract.Requires(ty != null);
Debug.Assert(ctx != null);
Debug.Assert(ty != null);
}
#endregion
}

View file

@ -18,16 +18,15 @@ Notes:
--*/
using System;
using System.Diagnostics;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// Solvers.
/// </summary>
[ContractVerification(true)]
public class Solver : Z3Object
{
/// <summary>
@ -37,7 +36,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<string>() != null);
return Native.Z3_solver_get_help(Context.nCtx, NativeObject);
}
@ -50,7 +48,7 @@ namespace Microsoft.Z3
{
set
{
Contract.Requires(value != null);
Debug.Assert(value != null);
Context.CheckContextMatch(value);
Native.Z3_solver_set_params(Context.nCtx, NativeObject, value.NativeObject);
@ -152,8 +150,8 @@ namespace Microsoft.Z3
/// </summary>
public void Assert(params BoolExpr[] constraints)
{
Contract.Requires(constraints != null);
Contract.Requires(Contract.ForAll(constraints, c => c != null));
Debug.Assert(constraints != null);
Debug.Assert(constraints.All(c => c != null));
Context.CheckContextMatch<BoolExpr>(constraints);
foreach (BoolExpr a in constraints)
@ -191,9 +189,9 @@ namespace Microsoft.Z3
/// </remarks>
public void AssertAndTrack(BoolExpr[] constraints, BoolExpr[] ps)
{
Contract.Requires(constraints != null);
Contract.Requires(Contract.ForAll(constraints, c => c != null));
Contract.Requires(Contract.ForAll(ps, c => c != null));
Debug.Assert(constraints != null);
Debug.Assert(constraints.All(c => c != null));
Debug.Assert(ps.All(c => c != null));
Context.CheckContextMatch<BoolExpr>(constraints);
Context.CheckContextMatch<BoolExpr>(ps);
if (constraints.Length != ps.Length)
@ -216,8 +214,8 @@ namespace Microsoft.Z3
/// </remarks>
public void AssertAndTrack(BoolExpr constraint, BoolExpr p)
{
Contract.Requires(constraint != null);
Contract.Requires(p != null);
Debug.Assert(constraint != null);
Debug.Assert(p != null);
Context.CheckContextMatch(constraint);
Context.CheckContextMatch(p);
@ -259,7 +257,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<BoolExpr[]>() != null);
ASTVector assertions = new ASTVector(Context, Native.Z3_solver_get_assertions(Context.nCtx, NativeObject));
return assertions.ToBoolExprArray();
@ -273,7 +270,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<BoolExpr[]>() != null);
ASTVector assertions = new ASTVector(Context, Native.Z3_solver_get_units(Context.nCtx, NativeObject));
return assertions.ToBoolExprArray();
@ -394,7 +390,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<Expr[]>() != null);
ASTVector core = new ASTVector(Context, Native.Z3_solver_get_unsat_core(Context.nCtx, NativeObject));
return core.ToBoolExprArray();
@ -408,7 +403,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<string>() != null);
return Native.Z3_solver_get_reason_unknown(Context.nCtx, NativeObject);
}
@ -455,8 +449,7 @@ namespace Microsoft.Z3
/// </summary>
public Solver Translate(Context ctx)
{
Contract.Requires(ctx != null);
Contract.Ensures(Contract.Result<Solver>() != null);
Debug.Assert(ctx != null);
return new Solver(ctx, Native.Z3_solver_translate(Context.nCtx, NativeObject, ctx.nCtx));
}
@ -475,7 +468,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<Statistics>() != null);
return new Statistics(Context, Native.Z3_solver_get_statistics(Context.nCtx, NativeObject));
}
@ -493,7 +485,7 @@ namespace Microsoft.Z3
internal Solver(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
this.BacktrackLevel = uint.MaxValue;
}

View file

@ -17,15 +17,14 @@ Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// The Sort class implements type information for ASTs.
/// </summary>
[ContractVerification(true)]
public class Sort : AST
{
/// <summary>
@ -100,7 +99,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<Symbol>() != null);
return Symbol.Create(Context, Native.Z3_get_sort_name(Context.nCtx, NativeObject));
}
}
@ -127,7 +125,7 @@ namespace Microsoft.Z3
/// <summary>
/// Sort constructor
/// </summary>
internal Sort(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
internal Sort(Context ctx, IntPtr obj) : base(ctx, obj) { Debug.Assert(ctx != null); }
#if DEBUG
internal override void CheckNativeObject(IntPtr obj)
@ -138,11 +136,9 @@ namespace Microsoft.Z3
}
#endif
[ContractVerification(true)]
new internal static Sort Create(Context ctx, IntPtr obj)
{
Contract.Requires(ctx != null);
Contract.Ensures(Contract.Result<Sort>() != null);
Debug.Assert(ctx != null);
switch ((Z3_sort_kind)Native.Z3_get_sort_kind(ctx.nCtx, obj))
{

View file

@ -18,14 +18,14 @@ Notes:
--*/
using System;
using System.Diagnostics.Contracts;
using System.Diagnostics;
namespace Microsoft.Z3
{
/// <summary>
/// Objects of this class track statistical information about solvers.
/// </summary>
[ContractVerification(true)]
public class Statistics : Z3Object
{
/// <summary>
@ -62,7 +62,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<string>() != null);
if (IsUInt)
return m_uint.ToString();
@ -124,9 +123,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<Entry[]>() != null);
Contract.Ensures(Contract.Result<Entry[]>().Length == this.Size);
Contract.Ensures(Contract.ForAll(0, Contract.Result<Entry[]>().Length, j => Contract.Result<Entry[]>()[j] != null));
uint n = Size;
Entry[] res = new Entry[n];
@ -153,7 +149,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<string[]>() != null);
uint n = Size;
string[] res = new string[n];
@ -184,7 +179,7 @@ namespace Microsoft.Z3
internal Statistics(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
internal class DecRefQueue : IDecRefQueue

View file

@ -17,6 +17,7 @@ Notes:
--*/
using System.Diagnostics;
using System;
namespace Microsoft.Z3

View file

@ -18,8 +18,8 @@ Notes:
--*/
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
@ -27,7 +27,6 @@ namespace Microsoft.Z3
/// <summary>
/// Named symbols
/// </summary>
[ContractVerification(true)]
public class StringSymbol : Symbol
{
/// <summary>
@ -38,7 +37,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<string>() != null);
if (!IsStringSymbol())
throw new Z3Exception("String requested from non-String symbol");
@ -50,13 +48,13 @@ namespace Microsoft.Z3
internal StringSymbol(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
internal StringSymbol(Context ctx, string s)
: base(ctx, Native.Z3_mk_string_symbol(ctx.nCtx, s))
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
#if DEBUG

View file

@ -18,15 +18,14 @@ Notes:
--*/
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// Symbols are used to name several term and type constructors.
/// </summary>
[ContractVerification(true)]
public class Symbol : Z3Object
{
/// <summary>
@ -84,7 +83,7 @@ namespace Microsoft.Z3
/// </summary>
public static bool operator !=(Symbol s1, Symbol s2)
{
return !(s1.NativeObject == s2.NativeObject);
return !(s1 == s2);
}
/// <summary>
@ -113,13 +112,12 @@ namespace Microsoft.Z3
/// </summary>
internal protected Symbol(Context ctx, IntPtr obj) : base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
internal static Symbol Create(Context ctx, IntPtr obj)
{
Contract.Requires(ctx != null);
Contract.Ensures(Contract.Result<Symbol>() != null);
Debug.Assert(ctx != null);
switch ((Z3_symbol_kind)Native.Z3_get_symbol_kind(ctx.nCtx, obj))
{

View file

@ -18,7 +18,7 @@ Notes:
--*/
using System;
using System.Diagnostics.Contracts;
using System.Diagnostics;
namespace Microsoft.Z3
{
@ -28,7 +28,6 @@ namespace Microsoft.Z3
/// and <c>Context.TacticNames</c>.
/// It may also be obtained using the command <c>(help-tactic)</c> in the SMT 2.0 front-end.
/// </summary>
[ContractVerification(true)]
public class Tactic : Z3Object
{
/// <summary>
@ -38,7 +37,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<string>() != null);
return Native.Z3_tactic_get_help(Context.nCtx, NativeObject);
}
@ -59,8 +57,7 @@ namespace Microsoft.Z3
/// </summary>
public ApplyResult Apply(Goal g, Params p = null)
{
Contract.Requires(g != null);
Contract.Ensures(Contract.Result<ApplyResult>() != null);
Debug.Assert(g != null);
Context.CheckContextMatch(g);
if (p == null)
@ -79,8 +76,7 @@ namespace Microsoft.Z3
{
get
{
Contract.Requires(g != null);
Contract.Ensures(Contract.Result<ApplyResult>() != null);
Debug.Assert(g != null);
return Apply(g);
}
@ -94,7 +90,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<Solver>() != null);
return Context.MkSolver(this);
}
@ -104,12 +99,12 @@ namespace Microsoft.Z3
internal Tactic(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
internal Tactic(Context ctx, string name)
: base(ctx, Native.Z3_mk_tactic(ctx.nCtx, name))
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
/// <summary>

View file

@ -18,14 +18,13 @@ Notes:
--*/
using System;
using System.Diagnostics.Contracts;
using System.Diagnostics;
namespace Microsoft.Z3
{
/// <summary>
/// Tuple sorts.
/// </summary>
[ContractVerification(true)]
public class TupleSort : Sort
{
/// <summary>
@ -35,7 +34,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<FuncDecl>() != null);
return new FuncDecl(Context, Native.Z3_get_tuple_sort_mk_decl(Context.nCtx, NativeObject));
}
@ -56,7 +54,6 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<FuncDecl[]>() != null);
uint n = NumFields;
FuncDecl[] res = new FuncDecl[n];
@ -70,8 +67,8 @@ namespace Microsoft.Z3
internal TupleSort(Context ctx, Symbol name, uint numFields, Symbol[] fieldNames, Sort[] fieldSorts)
: base(ctx, IntPtr.Zero)
{
Contract.Requires(ctx != null);
Contract.Requires(name != null);
Debug.Assert(ctx != null);
Debug.Assert(name != null);
IntPtr t = IntPtr.Zero;
IntPtr[] f = new IntPtr[numFields];

View file

@ -18,7 +18,7 @@ Notes:
--*/
using System;
using System.Diagnostics.Contracts;
using System.Diagnostics;
namespace Microsoft.Z3
{
@ -31,13 +31,13 @@ namespace Microsoft.Z3
internal UninterpretedSort(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
}
internal UninterpretedSort(Context ctx, Symbol s)
: base(ctx, Native.Z3_mk_uninterpreted_sort(ctx.nCtx, s.NativeObject))
{
Contract.Requires(ctx != null);
Contract.Requires(s != null);
Debug.Assert(ctx != null);
Debug.Assert(s != null);
}
#endregion
}

View file

@ -17,8 +17,8 @@ Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
@ -26,7 +26,6 @@ namespace Microsoft.Z3
/// Version information.
/// </summary>
/// <remarks>Note that this class is static.</remarks>
[ContractVerification(true)]
public static class Version
{
static Version() { }
@ -99,7 +98,6 @@ namespace Microsoft.Z3
/// </summary>
new public static string ToString()
{
Contract.Ensures(Contract.Result<string>() != null);
uint major = 0, minor = 0, build = 0, revision = 0;
Native.Z3_get_version(ref major, ref minor, ref build, ref revision);

View file

@ -17,6 +17,7 @@ Notes:
--*/
using System.Diagnostics;
using System;
namespace Microsoft.Z3

View file

@ -17,8 +17,8 @@ Notes:
--*/
using System.Diagnostics;
using System;
using System.Diagnostics.Contracts;
using System.Threading;
using System.Collections.Generic;
using System.Linq;
@ -29,7 +29,6 @@ namespace Microsoft.Z3
/// Internal base class for interfacing with native Z3 objects.
/// Should not be used externally.
/// </summary>
[ContractVerification(true)]
public class Z3Object : IDisposable
{
/// <summary>
@ -63,10 +62,9 @@ namespace Microsoft.Z3
#region Object Invariant
[ContractInvariantMethod]
private void ObjectInvariant()
{
Contract.Invariant(this.m_ctx != null);
Debug.Assert(this.m_ctx != null);
}
#endregion
@ -77,7 +75,7 @@ namespace Microsoft.Z3
internal Z3Object(Context ctx)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
Interlocked.Increment(ref ctx.refCount);
m_ctx = ctx;
@ -85,7 +83,7 @@ namespace Microsoft.Z3
internal Z3Object(Context ctx, IntPtr obj)
{
Contract.Requires(ctx != null);
Debug.Assert(ctx != null);
Interlocked.Increment(ref ctx.refCount);
m_ctx = ctx;
@ -119,16 +117,12 @@ namespace Microsoft.Z3
{
get
{
Contract.Ensures(Contract.Result<Context>() != null);
return m_ctx;
}
}
[Pure]
internal static IntPtr[] ArrayToNative(Z3Object[] a)
{
Contract.Ensures(a == null || Contract.Result<IntPtr[]>() != null);
Contract.Ensures(a == null || Contract.Result<IntPtr[]>().Length == a.Length);
if (a == null) return null;
IntPtr[] an = new IntPtr[a.Length];
@ -137,11 +131,8 @@ namespace Microsoft.Z3
return an;
}
[Pure]
internal static IntPtr[] EnumToNative<T>(IEnumerable<T> a) where T : Z3Object
{
Contract.Ensures(a == null || Contract.Result<IntPtr[]>() != null);
Contract.Ensures(a == null || Contract.Result<IntPtr[]>().Length == a.Count());
if (a == null) return null;
IntPtr[] an = new IntPtr[a.Count()];
@ -154,7 +145,6 @@ namespace Microsoft.Z3
return an;
}
[Pure]
internal static uint ArrayLength(Z3Object[] a)
{
return (a == null)?0:(uint)a.Length;

View file

@ -0,0 +1,15 @@
Z3 API for .NET Core
Z3's .NET API uses Code Contracts, which are not included in .NET Core. The
enclosed file called DummyContracts.cs provides stubs for the Code Contracts
functions, so that the API will compile, but not perform any contract
checking. To build this using .NET core, run (in this directory):
dotnet restore
dotnet build core.csproj -c Release
If you are building with the cmake system, you should first
copy over files that are produced by the compiler into
this directory. You need to copy over Native.cs and Enumeration.cs
-- good luck!

View file

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp1.0</TargetFramework>
<DefineConstants>$(DefineConstants);DOTNET_CORE</DefineConstants>
<DebugType>portable</DebugType>
<AssemblyName>Microsoft.Z3</AssemblyName>
<OutputType>Library</OutputType>
<PackageId>core</PackageId>
<PackageTargetFallback>$(PackageTargetFallback);dnxcore50</PackageTargetFallback>
<RuntimeFrameworkVersion>1.0.4</RuntimeFrameworkVersion>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\*.cs" Exclude="bin\**;obj\**;**\*.xproj;packages\**" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,10 @@
The default Z3 bindings for .NET are built for the .NET framework version 4.
Should the need arise, it is also possible to build them for .NET 3.5; the
instructions are as follows:
In the project properties of Microsoft.Z3.csproj:
- Under 'Application': Change Target framework to .NET Framework 3.5
- Under 'Build': Add FRAMEWORK_LT_4 to the conditional compilation symbols
- Remove the reference to System.Numerics
- Install the NuGet Package "Microsoft Code Contracts for Net3.5":
In the Package Manager Console enter Install-Package Code.Contract

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