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

Merge branch 'unstable' of https://github.com/Z3Prover/z3 into contrib

Conflicts:
	README
	src/api/ml/build-lib.sh
	src/api/ml/z3.ml
	src/api/ml/z3.mli
	src/api/ml/z3_stubs.c
This commit is contained in:
Christoph M. Wintersteiger 2015-04-28 15:19:08 +01:00
commit 1d49f61b9a
395 changed files with 46184 additions and 69505 deletions

View file

@ -300,7 +300,7 @@ extern "C" {
Z3_CATCH_RETURN(-1);
}
char const * Z3_API Z3_get_symbol_string(Z3_context c, Z3_symbol s) {
Z3_API char const * Z3_get_symbol_string(Z3_context c, Z3_symbol s) {
Z3_TRY;
LOG_Z3_get_symbol_string(c, s);
RESET_ERROR_CODE();
@ -648,6 +648,12 @@ extern "C" {
else if (fid == mk_c(c)->get_datalog_fid() && k == datalog::DL_FINITE_SORT) {
return Z3_FINITE_DOMAIN_SORT;
}
else if (fid == mk_c(c)->get_fpa_fid() && k == FLOATING_POINT_SORT) {
return Z3_FLOATING_POINT_SORT;
}
else if (fid == mk_c(c)->get_fpa_fid() && k == ROUNDING_MODE_SORT) {
return Z3_ROUNDING_MODE_SORT;
}
else {
return Z3_UNKNOWN_SORT;
}
@ -817,7 +823,7 @@ extern "C" {
Z3_CATCH_RETURN(0);
}
char const * Z3_API Z3_ast_to_string(Z3_context c, Z3_ast a) {
Z3_API char const * Z3_ast_to_string(Z3_context c, Z3_ast a) {
Z3_TRY;
LOG_Z3_ast_to_string(c, a);
RESET_ERROR_CODE();
@ -860,11 +866,11 @@ extern "C" {
Z3_CATCH_RETURN(0);
}
char const * Z3_API Z3_sort_to_string(Z3_context c, Z3_sort s) {
Z3_API char const * Z3_sort_to_string(Z3_context c, Z3_sort s) {
return Z3_ast_to_string(c, reinterpret_cast<Z3_ast>(s));
}
char const * Z3_API Z3_func_decl_to_string(Z3_context c, Z3_func_decl f) {
Z3_API char const * Z3_func_decl_to_string(Z3_context c, Z3_func_decl f) {
return Z3_ast_to_string(c, reinterpret_cast<Z3_ast>(f));
}
@ -1113,6 +1119,62 @@ extern "C" {
return Z3_OP_UNINTERPRETED;
}
}
if (mk_c(c)->get_fpa_fid() == _d->get_family_id()) {
switch (_d->get_decl_kind()) {
case OP_FPA_RM_NEAREST_TIES_TO_EVEN: return Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN;
case OP_FPA_RM_NEAREST_TIES_TO_AWAY: return Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY;
case OP_FPA_RM_TOWARD_POSITIVE: return Z3_OP_FPA_RM_TOWARD_POSITIVE;
case OP_FPA_RM_TOWARD_NEGATIVE: return Z3_OP_FPA_RM_TOWARD_NEGATIVE;
case OP_FPA_RM_TOWARD_ZERO: return Z3_OP_FPA_RM_TOWARD_ZERO;
case OP_FPA_NUM: return Z3_OP_FPA_NUM;
case OP_FPA_PLUS_INF: return Z3_OP_FPA_PLUS_INF;
case OP_FPA_MINUS_INF: return Z3_OP_FPA_MINUS_INF;
case OP_FPA_NAN: return Z3_OP_FPA_NAN;
case OP_FPA_MINUS_ZERO: return Z3_OP_FPA_MINUS_ZERO;
case OP_FPA_PLUS_ZERO: return Z3_OP_FPA_PLUS_ZERO;
case OP_FPA_ADD: return Z3_OP_FPA_ADD;
case OP_FPA_SUB: return Z3_OP_FPA_SUB;
case OP_FPA_NEG: return Z3_OP_FPA_NEG;
case OP_FPA_MUL: return Z3_OP_FPA_MUL;
case OP_FPA_DIV: return Z3_OP_FPA_DIV;
case OP_FPA_REM: return Z3_OP_FPA_REM;
case OP_FPA_ABS: return Z3_OP_FPA_ABS;
case OP_FPA_MIN: return Z3_OP_FPA_MIN;
case OP_FPA_MAX: return Z3_OP_FPA_MAX;
case OP_FPA_FMA: return Z3_OP_FPA_FMA;
case OP_FPA_SQRT: return Z3_OP_FPA_SQRT;
case OP_FPA_EQ: return Z3_OP_FPA_EQ;
case OP_FPA_ROUND_TO_INTEGRAL: return Z3_OP_FPA_ROUND_TO_INTEGRAL;
case OP_FPA_LT: return Z3_OP_FPA_LT;
case OP_FPA_GT: return Z3_OP_FPA_GT;
case OP_FPA_LE: return Z3_OP_FPA_LE;
case OP_FPA_GE: return Z3_OP_FPA_GE;
case OP_FPA_IS_NAN: return Z3_OP_FPA_IS_NAN;
case OP_FPA_IS_INF: return Z3_OP_FPA_IS_INF;
case OP_FPA_IS_ZERO: return Z3_OP_FPA_IS_ZERO;
case OP_FPA_IS_NORMAL: return Z3_OP_FPA_IS_NORMAL;
case OP_FPA_IS_SUBNORMAL: return Z3_OP_FPA_IS_SUBNORMAL;
case OP_FPA_IS_NEGATIVE: return Z3_OP_FPA_IS_NEGATIVE;
case OP_FPA_IS_POSITIVE: return Z3_OP_FPA_IS_POSITIVE;
case OP_FPA_FP: return Z3_OP_FPA_FP;
case OP_FPA_TO_FP: return Z3_OP_FPA_TO_FP;
case OP_FPA_TO_FP_UNSIGNED: return Z3_OP_FPA_TO_FP_UNSIGNED;
case OP_FPA_TO_UBV: return Z3_OP_FPA_TO_UBV;
case OP_FPA_TO_SBV: return Z3_OP_FPA_TO_SBV;
case OP_FPA_TO_REAL: return Z3_OP_FPA_TO_REAL;
case OP_FPA_TO_IEEE_BV: return Z3_OP_FPA_TO_IEEE_BV;
case OP_FPA_INTERNAL_BVWRAP:
case OP_FPA_INTERNAL_BVUNWRAP:
case OP_FPA_INTERNAL_TO_UBV_UNSPECIFIED:
case OP_FPA_INTERNAL_TO_SBV_UNSPECIFIED:
case OP_FPA_INTERNAL_TO_REAL_UNSPECIFIED:
return Z3_OP_UNINTERPRETED;
default:
UNREACHABLE();
return Z3_OP_UNINTERPRETED;
}
}
if (mk_c(c)->m().get_label_family_id() == _d->get_family_id()) {
switch(_d->get_decl_kind()) {

View file

@ -88,6 +88,8 @@ namespace api {
m_arith_util(m()),
m_bv_util(m()),
m_datalog_util(m()),
m_fpa_util(m()),
m_dtutil(m()),
m_last_result(m()),
m_ast_trail(m()),
m_replay_stack() {
@ -112,6 +114,7 @@ namespace api {
m_array_fid = m().mk_family_id("array");
m_dt_fid = m().mk_family_id("datatype");
m_datalog_fid = m().mk_family_id("datalog_relation");
m_fpa_fid = m().mk_family_id("fpa");
m_dt_plugin = static_cast<datatype_decl_plugin*>(m().get_plugin(m_dt_fid));
if (!m_user_ref_count) {
@ -546,12 +549,12 @@ extern "C" {
}
}
char const * Z3_API Z3_get_error_msg(Z3_error_code err) {
Z3_API char const * Z3_get_error_msg(Z3_error_code err) {
LOG_Z3_get_error_msg(err);
return _get_error_msg_ex(0, err);
}
char const * Z3_API Z3_get_error_msg_ex(Z3_context c, Z3_error_code err) {
Z3_API char const * Z3_get_error_msg_ex(Z3_context c, Z3_error_code err) {
LOG_Z3_get_error_msg_ex(c, err);
return _get_error_msg_ex(c, err);
}
@ -575,7 +578,7 @@ extern "C" {
};
ast_manager & Z3_API Z3_get_manager(__in Z3_context c) {
Z3_API ast_manager& Z3_get_manager(__in Z3_context c) {
return mk_c(c)->m();
}

View file

@ -27,6 +27,7 @@ Revision History:
#include"bv_decl_plugin.h"
#include"datatype_decl_plugin.h"
#include"dl_decl_plugin.h"
#include"fpa_decl_plugin.h"
#include"smt_kernel.h"
#include"smt_params.h"
#include"event_handler.h"
@ -56,6 +57,8 @@ namespace api {
arith_util m_arith_util;
bv_util m_bv_util;
datalog::dl_decl_util m_datalog_util;
fpa_util m_fpa_util;
datatype_util m_dtutil;
// Support for old solver API
smt_params m_fparams;
@ -75,6 +78,7 @@ namespace api {
family_id m_bv_fid;
family_id m_dt_fid;
family_id m_datalog_fid;
family_id m_fpa_fid;
datatype_decl_plugin * m_dt_plugin;
std::string m_string_buffer; // temporary buffer used to cache strings sent to the "external" world.
@ -115,12 +119,15 @@ namespace api {
arith_util & autil() { return m_arith_util; }
bv_util & bvutil() { return m_bv_util; }
datalog::dl_decl_util & datalog_util() { return m_datalog_util; }
fpa_util & fpautil() { return m_fpa_util; }
datatype_util& dtutil() { return m_dtutil; }
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; }
family_id get_bv_fid() const { return m_bv_fid; }
family_id get_dt_fid() const { return m_dt_fid; }
family_id get_datalog_fid() const { return m_datalog_fid; }
family_id get_fpa_fid() const { return m_fpa_fid; }
datatype_decl_plugin * get_dt_plugin() const { return m_dt_plugin; }
Z3_error_code get_error_code() const { return m_error_code; }

View file

@ -36,7 +36,7 @@ extern "C" {
RESET_ERROR_CODE();
mk_c(c)->reset_last_result();
ast_manager& m = mk_c(c)->m();
datatype_util dt_util(m);
datatype_util& dt_util = mk_c(c)->dtutil();
sort_ref_vector tuples(m);
sort* tuple;
@ -102,7 +102,7 @@ extern "C" {
RESET_ERROR_CODE();
mk_c(c)->reset_last_result();
ast_manager& m = mk_c(c)->m();
datatype_util dt_util(m);
datatype_util& dt_util = mk_c(c)->dtutil();
sort_ref_vector sorts(m);
sort* e;
@ -451,7 +451,7 @@ extern "C" {
RESET_ERROR_CODE();
CHECK_VALID_AST(t, 0);
sort * _t = to_sort(t);
datatype_util dt_util(mk_c(c)->m());
datatype_util& dt_util = mk_c(c)->dtutil();
if (!dt_util.is_datatype(_t)) {
SET_ERROR_CODE(Z3_INVALID_ARG);
@ -470,13 +470,13 @@ extern "C" {
RESET_ERROR_CODE();
CHECK_VALID_AST(t, 0);
sort * _t = to_sort(t);
datatype_util dt_util(mk_c(c)->m());
datatype_util& dt_util = mk_c(c)->dtutil();
if (!dt_util.is_datatype(_t)) {
SET_ERROR_CODE(Z3_INVALID_ARG);
return 0;
}
ptr_vector<func_decl> const * decls = dt_util.get_datatype_constructors(_t);
if (!decls || idx >= decls->size()) {
if (idx >= decls->size()) {
SET_ERROR_CODE(Z3_INVALID_ARG);
return 0;
}
@ -499,16 +499,16 @@ extern "C" {
LOG_Z3_get_datatype_sort_recognizer(c, t, idx);
RESET_ERROR_CODE();
sort * _t = to_sort(t);
datatype_util dt_util(mk_c(c)->m());
datatype_util& dt_util = mk_c(c)->dtutil();
if (!dt_util.is_datatype(_t)) {
SET_ERROR_CODE(Z3_INVALID_ARG);
RETURN_Z3(0);
}
ptr_vector<func_decl> const * decls = dt_util.get_datatype_constructors(_t);
if (!decls || idx >= decls->size()) {
if (idx >= decls->size()) {
SET_ERROR_CODE(Z3_INVALID_ARG);
RETURN_Z3(0);
return 0;
}
func_decl* decl = (*decls)[idx];
decl = dt_util.get_constructor_recognizer(decl);
@ -522,16 +522,16 @@ extern "C" {
LOG_Z3_get_datatype_sort_constructor_accessor(c, t, idx_c, idx_a);
RESET_ERROR_CODE();
sort * _t = to_sort(t);
datatype_util dt_util(mk_c(c)->m());
datatype_util& dt_util = mk_c(c)->dtutil();
if (!dt_util.is_datatype(_t)) {
SET_ERROR_CODE(Z3_INVALID_ARG);
RETURN_Z3(0);
}
ptr_vector<func_decl> const * decls = dt_util.get_datatype_constructors(_t);
if (!decls || idx_c >= decls->size()) {
if (idx_c >= decls->size()) {
SET_ERROR_CODE(Z3_INVALID_ARG);
RETURN_Z3(0);
return 0;
}
func_decl* decl = (*decls)[idx_c];
if (decl->get_arity() <= idx_a) {
@ -555,7 +555,7 @@ extern "C" {
LOG_Z3_get_tuple_sort_mk_decl(c, t);
RESET_ERROR_CODE();
sort * tuple = to_sort(t);
datatype_util dt_util(mk_c(c)->m());
datatype_util& dt_util = mk_c(c)->dtutil();
if (!dt_util.is_datatype(tuple) || dt_util.is_recursive(tuple) || dt_util.get_datatype_num_constructors(tuple) != 1) {
SET_ERROR_CODE(Z3_INVALID_ARG);
RETURN_Z3(0);
@ -570,7 +570,7 @@ extern "C" {
LOG_Z3_get_tuple_sort_num_fields(c, t);
RESET_ERROR_CODE();
sort * tuple = to_sort(t);
datatype_util dt_util(mk_c(c)->m());
datatype_util& dt_util = mk_c(c)->dtutil();
if (!dt_util.is_datatype(tuple) || dt_util.is_recursive(tuple) || dt_util.get_datatype_num_constructors(tuple) != 1) {
SET_ERROR_CODE(Z3_INVALID_ARG);
return 0;
@ -593,7 +593,7 @@ extern "C" {
LOG_Z3_get_tuple_sort_field_decl(c, t, i);
RESET_ERROR_CODE();
sort * tuple = to_sort(t);
datatype_util dt_util(mk_c(c)->m());
datatype_util& dt_util = mk_c(c)->dtutil();
if (!dt_util.is_datatype(tuple) || dt_util.is_recursive(tuple) || dt_util.get_datatype_num_constructors(tuple) != 1) {
SET_ERROR_CODE(Z3_INVALID_ARG);
RETURN_Z3(0);

842
src/api/api_fpa.cpp Normal file
View file

@ -0,0 +1,842 @@
/*++
Copyright (c) 2013 Microsoft Corporation
Module Name:
api_fpa.cpp
Abstract:
Additional APIs for floating-point arithmetic (FP).
Author:
Christoph M. Wintersteiger (cwinter) 2013-06-05
Notes:
--*/
#include<iostream>
#include"z3.h"
#include"api_log_macros.h"
#include"api_context.h"
#include"fpa_decl_plugin.h"
extern "C" {
Z3_sort Z3_API Z3_mk_fpa_rounding_mode_sort(Z3_context c) {
Z3_TRY;
LOG_Z3_mk_fpa_rounding_mode_sort(c);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
sort * s = ctx->fpautil().mk_rm_sort();
mk_c(c)->save_ast_trail(s);
RETURN_Z3(of_sort(s));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_round_nearest_ties_to_even(Z3_context c) {
Z3_TRY;
LOG_Z3_mk_fpa_round_nearest_ties_to_even(c);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_round_nearest_ties_to_even();
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_rne(Z3_context c) {
Z3_TRY;
LOG_Z3_mk_fpa_rne(c);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_round_nearest_ties_to_even();
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_round_nearest_ties_to_away(Z3_context c) {
Z3_TRY;
LOG_Z3_mk_fpa_round_nearest_ties_to_away(c);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_round_nearest_ties_to_away();
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_rna(Z3_context c) {
Z3_TRY;
LOG_Z3_mk_fpa_rna(c);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_round_nearest_ties_to_away();
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_round_toward_positive(Z3_context c) {
Z3_TRY;
LOG_Z3_mk_fpa_round_toward_positive(c);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_round_toward_positive();
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_rtp(Z3_context c) {
Z3_TRY;
LOG_Z3_mk_fpa_rtp(c);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_round_toward_positive();
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_round_toward_negative(Z3_context c) {
Z3_TRY;
LOG_Z3_mk_fpa_round_toward_negative(c);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_round_toward_negative();
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_rtn(Z3_context c) {
Z3_TRY;
LOG_Z3_mk_fpa_rtn(c);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_round_toward_negative();
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_round_toward_zero(Z3_context c) {
Z3_TRY;
LOG_Z3_mk_fpa_round_toward_zero(c);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_round_toward_zero();
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_rtz(Z3_context c) {
Z3_TRY;
LOG_Z3_mk_fpa_rtz(c);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_round_toward_zero();
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_sort Z3_API Z3_mk_fpa_sort(Z3_context c, unsigned ebits, unsigned sbits) {
Z3_TRY;
LOG_Z3_mk_fpa_sort(c, ebits, sbits);
RESET_ERROR_CODE();
if (ebits < 2 || sbits < 3) {
SET_ERROR_CODE(Z3_INVALID_ARG);
}
api::context * ctx = mk_c(c);
sort * s = ctx->fpautil().mk_float_sort(ebits, sbits);
ctx->save_ast_trail(s);
RETURN_Z3(of_sort(s));
Z3_CATCH_RETURN(0);
}
Z3_sort Z3_API Z3_mk_fpa_sort_half(Z3_context c) {
return Z3_mk_fpa_sort(c, 5, 11);
}
Z3_sort Z3_API Z3_mk_fpa_sort_16(Z3_context c) {
return Z3_mk_fpa_sort(c, 5, 11);
}
Z3_sort Z3_API Z3_mk_fpa_sort_single(Z3_context c) {
return Z3_mk_fpa_sort(c, 8, 24);
}
Z3_sort Z3_API Z3_mk_fpa_sort_32(Z3_context c) {
return Z3_mk_fpa_sort(c, 8, 24);
}
Z3_sort Z3_API Z3_mk_fpa_sort_double(Z3_context c) {
return Z3_mk_fpa_sort(c, 11, 53);
}
Z3_sort Z3_API Z3_mk_fpa_sort_64(Z3_context c) {
return Z3_mk_fpa_sort(c, 11, 53);
}
Z3_sort Z3_API Z3_mk_fpa_sort_quadruple(Z3_context c) {
return Z3_mk_fpa_sort(c, 15, 113);
}
Z3_sort Z3_API Z3_mk_fpa_sort_128(Z3_context c) {
return Z3_mk_fpa_sort(c, 15, 113);
}
Z3_ast Z3_API Z3_mk_fpa_nan(Z3_context c, Z3_sort s) {
Z3_TRY;
LOG_Z3_mk_fpa_nan(c, s);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_nan(to_sort(s));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_inf(Z3_context c, Z3_sort s, Z3_bool negative) {
Z3_TRY;
LOG_Z3_mk_fpa_inf(c, s, negative);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = negative != 0 ? 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(0);
}
Z3_ast Z3_API Z3_mk_fpa_zero(Z3_context c, Z3_sort s, Z3_bool negative) {
Z3_TRY;
LOG_Z3_mk_fpa_inf(c, s, negative);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = negative != 0 ? 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(0);
}
Z3_ast Z3_API Z3_mk_fpa_fp(Z3_context c, Z3_ast sgn, Z3_ast exp, Z3_ast sig) {
Z3_TRY;
LOG_Z3_mk_fpa_fp(c, sgn, sig, exp);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_fp(to_expr(sgn), to_expr(sig), to_expr(exp));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_numeral_float(Z3_context c, float v, Z3_sort ty) {
Z3_TRY;
LOG_Z3_mk_fpa_numeral_float(c, v, ty);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
scoped_mpf tmp(ctx->fpautil().fm());
ctx->fpautil().fm().set(tmp,
ctx->fpautil().get_ebits(to_sort(ty)),
ctx->fpautil().get_sbits(to_sort(ty)),
v);
expr * a = ctx->fpautil().mk_value(tmp);
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_numeral_double(Z3_context c, double v, Z3_sort ty) {
Z3_TRY;
LOG_Z3_mk_fpa_numeral_double(c, v, ty);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
scoped_mpf tmp(ctx->fpautil().fm());
ctx->fpautil().fm().set(tmp, ctx->fpautil().get_ebits(to_sort(ty)), ctx->fpautil().get_sbits(to_sort(ty)), v);
expr * a = ctx->fpautil().mk_value(tmp);
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_numeral_int(Z3_context c, signed v, Z3_sort ty) {
Z3_TRY;
LOG_Z3_mk_fpa_numeral_int(c, v, ty);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
scoped_mpf tmp(ctx->fpautil().fm());
ctx->fpautil().fm().set(tmp,
ctx->fpautil().get_ebits(to_sort(ty)),
ctx->fpautil().get_sbits(to_sort(ty)),
v);
expr * a = ctx->fpautil().mk_value(tmp);
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_numeral_int_uint(Z3_context c, Z3_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();
api::context * ctx = mk_c(c);
scoped_mpf tmp(ctx->fpautil().fm());
ctx->fpautil().fm().set(tmp,
ctx->fpautil().get_ebits(to_sort(ty)),
ctx->fpautil().get_sbits(to_sort(ty)),
sgn != 0, sig, exp);
expr * a = ctx->fpautil().mk_value(tmp);
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_numeral_int64_uint64(Z3_context c, Z3_bool sgn, __int64 exp, __uint64 sig, Z3_sort ty) {
Z3_TRY;
LOG_Z3_mk_fpa_numeral_int64_uint64(c, sgn, exp, sig, ty);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
scoped_mpf tmp(ctx->fpautil().fm());
ctx->fpautil().fm().set(tmp,
ctx->fpautil().get_ebits(to_sort(ty)),
ctx->fpautil().get_sbits(to_sort(ty)),
sgn != 0, sig, exp);
expr * a = ctx->fpautil().mk_value(tmp);
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_abs(Z3_context c, Z3_ast t) {
Z3_TRY;
LOG_Z3_mk_fpa_abs(c, t);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_abs(to_expr(t));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_neg(Z3_context c, Z3_ast t) {
Z3_TRY;
LOG_Z3_mk_fpa_neg(c, t);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_neg(to_expr(t));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_add(Z3_context c, Z3_ast rm, Z3_ast t1, Z3_ast t2) {
Z3_TRY;
LOG_Z3_mk_fpa_add(c, rm, t1, t2);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_add(to_expr(rm), to_expr(t1), to_expr(t2));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_sub(Z3_context c, Z3_ast rm, Z3_ast t1, Z3_ast t2) {
Z3_TRY;
LOG_Z3_mk_fpa_add(c, rm, t1, t2);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_sub(to_expr(rm), to_expr(t1), to_expr(t2));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_mul(Z3_context c, Z3_ast rm, Z3_ast t1, Z3_ast t2) {
Z3_TRY;
LOG_Z3_mk_fpa_add(c, rm, t1, t2);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_mul(to_expr(rm), to_expr(t1), to_expr(t2));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_div(Z3_context c, Z3_ast rm, Z3_ast t1, Z3_ast t2) {
Z3_TRY;
LOG_Z3_mk_fpa_add(c, rm, t1, t2);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_div(to_expr(rm), to_expr(t1), to_expr(t2));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_fma(Z3_context c, Z3_ast rm, Z3_ast t1, Z3_ast t2, Z3_ast t3) {
Z3_TRY;
LOG_Z3_mk_fpa_fma(c, rm, t1, t2, t3);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_fma(to_expr(rm), to_expr(t1), to_expr(t2), to_expr(t3));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_sqrt(Z3_context c, Z3_ast rm, Z3_ast t) {
Z3_TRY;
LOG_Z3_mk_fpa_sqrt(c, rm, t);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_sqrt(to_expr(rm), to_expr(t));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_rem(Z3_context c, Z3_ast t1, Z3_ast t2) {
Z3_TRY;
LOG_Z3_mk_fpa_rem(c, t1, t2);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_rem(to_expr(t1), to_expr(t2));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_round_to_integral(Z3_context c, Z3_ast rm, Z3_ast t) {
Z3_TRY;
LOG_Z3_mk_fpa_round_to_integral(c, rm, t);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_round_to_integral(to_expr(rm), to_expr(t));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_min(Z3_context c, Z3_ast t1, Z3_ast t2) {
Z3_TRY;
LOG_Z3_mk_fpa_min(c, t1, t2);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_min(to_expr(t1), to_expr(t2));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_max(Z3_context c, Z3_ast t1, Z3_ast t2) {
Z3_TRY;
LOG_Z3_mk_fpa_max(c, t1, t2);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
Z3_ast r = of_ast(ctx->fpautil().mk_max(to_expr(t1), to_expr(t2)));
RETURN_Z3(r);
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_leq(Z3_context c, Z3_ast t1, Z3_ast t2) {
Z3_TRY;
LOG_Z3_mk_fpa_leq(c, t1, t2);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_le(to_expr(t1), to_expr(t2));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_lt(Z3_context c, Z3_ast t1, Z3_ast t2) {
Z3_TRY;
LOG_Z3_mk_fpa_lt(c, t1, t2);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_lt(to_expr(t1), to_expr(t2));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_geq(Z3_context c, Z3_ast t1, Z3_ast t2) {
Z3_TRY;
LOG_Z3_mk_fpa_geq(c, t1, t2);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_ge(to_expr(t1), to_expr(t2));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_gt(Z3_context c, Z3_ast t1, Z3_ast t2) {
Z3_TRY;
LOG_Z3_mk_fpa_gt(c, t1, t2);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_gt(to_expr(t1), to_expr(t2));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_eq(Z3_context c, Z3_ast t1, Z3_ast t2) {
Z3_TRY;
LOG_Z3_mk_fpa_eq(c, t1, t2);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_float_eq(to_expr(t1), to_expr(t2));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_is_normal(Z3_context c, Z3_ast t) {
Z3_TRY;
LOG_Z3_mk_fpa_is_normal(c, t);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_is_normal(to_expr(t));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_is_subnormal(Z3_context c, Z3_ast t) {
Z3_TRY;
LOG_Z3_mk_fpa_is_subnormal(c, t);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_is_subnormal(to_expr(t));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_is_zero(Z3_context c, Z3_ast t) {
Z3_TRY;
LOG_Z3_mk_fpa_is_zero(c, t);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_is_zero(to_expr(t));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_is_infinite(Z3_context c, Z3_ast t) {
Z3_TRY;
LOG_Z3_mk_fpa_is_infinite(c, t);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_is_inf(to_expr(t));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_is_nan(Z3_context c, Z3_ast t) {
Z3_TRY;
LOG_Z3_mk_fpa_is_nan(c, t);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_is_nan(to_expr(t));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_is_negative(Z3_context c, Z3_ast t) {
Z3_TRY;
LOG_Z3_mk_fpa_is_negative(c, t);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_is_negative(to_expr(t));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_is_positive(Z3_context c, Z3_ast t) {
Z3_TRY;
LOG_Z3_mk_fpa_is_positive(c, t);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_is_positive(to_expr(t));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_to_fp_bv(Z3_context c, Z3_ast bv, Z3_sort s) {
Z3_TRY;
LOG_Z3_mk_fpa_to_fp_bv(c, bv, s);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
fpa_util & fu = ctx->fpautil();
if (!ctx->bvutil().is_bv(to_expr(bv)) ||
!fu.is_float(to_sort(s))) {
SET_ERROR_CODE(Z3_INVALID_ARG);
return 0;
}
expr * a = fu.mk_to_fp(to_sort(s), to_expr(bv));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_to_fp_float(Z3_context c, Z3_ast rm, Z3_ast t, Z3_sort s) {
Z3_TRY;
LOG_Z3_mk_fpa_to_fp_float(c, rm, t, s);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
fpa_util & fu = ctx->fpautil();
if (!fu.is_rm(to_expr(rm)) ||
!fu.is_float(to_expr(t)) ||
!fu.is_float(to_sort(s))) {
SET_ERROR_CODE(Z3_INVALID_ARG);
return 0;
}
expr * a = fu.mk_to_fp(to_sort(s), to_expr(rm), to_expr(t));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_to_fp_real(Z3_context c, Z3_ast rm, Z3_ast t, Z3_sort s) {
Z3_TRY;
LOG_Z3_mk_fpa_to_fp_real(c, rm, t, s);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
fpa_util & fu = ctx->fpautil();
if (!fu.is_rm(to_expr(rm)) ||
!ctx->autil().is_real(to_expr(t)) ||
!fu.is_float(to_sort(s))) {
SET_ERROR_CODE(Z3_INVALID_ARG);
return 0;
}
expr * a = fu.mk_to_fp(to_sort(s), to_expr(rm), to_expr(t));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_to_fp_signed(Z3_context c, Z3_ast rm, Z3_ast t, Z3_sort s) {
Z3_TRY;
LOG_Z3_mk_fpa_to_fp_signed(c, rm, t, s);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
fpa_util & fu = ctx->fpautil();
if (!fu.is_rm(to_expr(rm)) ||
!ctx->bvutil().is_bv(to_expr(t)) ||
!fu.is_float(to_sort(s))) {
SET_ERROR_CODE(Z3_INVALID_ARG);
return 0;
}
expr * a = fu.mk_to_fp(to_sort(s), to_expr(rm), to_expr(t));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_to_fp_unsigned(Z3_context c, Z3_ast rm, Z3_ast t, Z3_sort s) {
Z3_TRY;
LOG_Z3_mk_fpa_to_fp_unsigned(c, rm, t, s);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
fpa_util & fu = ctx->fpautil();
if (!fu.is_rm(to_expr(rm)) ||
!ctx->bvutil().is_bv(to_expr(t)) ||
!fu.is_float(to_sort(s))) {
SET_ERROR_CODE(Z3_INVALID_ARG);
return 0;
}
expr * a = fu.mk_to_fp_unsigned(to_sort(s), to_expr(rm), to_expr(t));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_to_ubv(Z3_context c, Z3_ast rm, Z3_ast t, unsigned sz) {
Z3_TRY;
LOG_Z3_mk_fpa_to_ubv(c, rm, t, sz);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_to_ubv(to_expr(rm), to_expr(t), sz);
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_to_sbv(Z3_context c, Z3_ast rm, Z3_ast t, unsigned sz) {
Z3_TRY;
LOG_Z3_mk_fpa_to_sbv(c, rm, t, sz);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_to_sbv(to_expr(rm), to_expr(t), sz);
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_to_real(Z3_context c, Z3_ast t) {
Z3_TRY;
LOG_Z3_mk_fpa_to_real(c, t);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
expr * a = ctx->fpautil().mk_to_real(to_expr(t));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
unsigned Z3_API Z3_fpa_get_ebits(Z3_context c, Z3_sort s) {
Z3_TRY;
LOG_Z3_fpa_get_ebits(c, s);
RESET_ERROR_CODE();
CHECK_NON_NULL(s, 0);
return mk_c(c)->fpautil().get_ebits(to_sort(s));
Z3_CATCH_RETURN(0);
}
unsigned Z3_API Z3_fpa_get_sbits(Z3_context c, Z3_sort s) {
Z3_TRY;
LOG_Z3_fpa_get_ebits(c, s);
RESET_ERROR_CODE();
CHECK_NON_NULL(s, 0);
return mk_c(c)->fpautil().get_sbits(to_sort(s));
Z3_CATCH_RETURN(0);
}
Z3_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();
ast_manager & m = mk_c(c)->m();
mpf_manager & mpfm = mk_c(c)->fpautil().fm();
fpa_decl_plugin * plugin = (fpa_decl_plugin*)m.get_plugin(mk_c(c)->get_fpa_fid());
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);
return 0;
}
*sgn = (mpfm.is_nan(val)) ? 0 : mpfm.sgn(val);
return r;
Z3_CATCH_RETURN(0);
}
Z3_string Z3_API Z3_fpa_get_numeral_significand_string(__in Z3_context c, __in Z3_ast t) {
Z3_TRY;
LOG_Z3_fpa_get_numeral_significand_string(c, t);
RESET_ERROR_CODE();
ast_manager & m = mk_c(c)->m();
mpf_manager & mpfm = mk_c(c)->fpautil().fm();
unsynch_mpz_manager & mpzm = mpfm.mpz_manager();
unsynch_mpq_manager & mpqm = mpfm.mpq_manager();
fpa_decl_plugin * plugin = (fpa_decl_plugin*)m.get_plugin(mk_c(c)->get_fpa_fid());
scoped_mpf val(mpfm);
if (!plugin->is_numeral(to_expr(t), val)) {
SET_ERROR_CODE(Z3_INVALID_ARG);
return "";
}
else if (!mpfm.is_regular(val)) {
SET_ERROR_CODE(Z3_INVALID_ARG)
return "";
}
unsigned sbits = val.get().get_sbits();
scoped_mpq q(mpqm);
scoped_mpz sn(mpzm);
mpfm.sig_normalized(val, sn);
mpqm.set(q, sn);
mpqm.div(q, mpfm.m_powers2(sbits - 1), q);
std::stringstream ss;
mpqm.display_decimal(ss, q, sbits);
return mk_c(c)->mk_external_string(ss.str());
Z3_CATCH_RETURN("");
}
Z3_string Z3_API Z3_fpa_get_numeral_exponent_string(__in Z3_context c, __in Z3_ast t) {
Z3_TRY;
LOG_Z3_fpa_get_numeral_exponent_string(c, t);
RESET_ERROR_CODE();
ast_manager & m = mk_c(c)->m();
mpf_manager & mpfm = mk_c(c)->fpautil().fm();
fpa_decl_plugin * plugin = (fpa_decl_plugin*)m.get_plugin(mk_c(c)->get_fpa_fid());
scoped_mpf val(mpfm);
bool r = plugin->is_numeral(to_expr(t), val);
if (!r) {
SET_ERROR_CODE(Z3_INVALID_ARG);
return "";
}
else if (!mpfm.is_normal(val) && !mpfm.is_denormal(val)) {
SET_ERROR_CODE(Z3_INVALID_ARG)
return "";
}
mpf_exp_t exp = mpfm.exp_normalized(val);
std::stringstream ss;
ss << exp;
return mk_c(c)->mk_external_string(ss.str());
Z3_CATCH_RETURN("");
}
Z3_bool Z3_API Z3_fpa_get_numeral_exponent_int64(__in Z3_context c, __in Z3_ast t, __out __int64 * n) {
Z3_TRY;
LOG_Z3_fpa_get_numeral_exponent_string(c, t);
RESET_ERROR_CODE();
ast_manager & m = mk_c(c)->m();
mpf_manager & mpfm = mk_c(c)->fpautil().fm();
fpa_decl_plugin * plugin = (fpa_decl_plugin*)m.get_plugin(mk_c(c)->get_fpa_fid());
scoped_mpf val(mpfm);
bool r = plugin->is_numeral(to_expr(t), val);
if (!r) {
SET_ERROR_CODE(Z3_INVALID_ARG);
return 0;
}
*n = mpfm.exp(val);
return 1;
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_to_ieee_bv(Z3_context c, Z3_ast t) {
Z3_TRY;
LOG_Z3_mk_fpa_to_ieee_bv(c, t);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
Z3_ast r = of_ast(ctx->fpautil().mk_float_to_ieee_bv(to_expr(t)));
RETURN_Z3(r);
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_fpa_to_fp_int_real(Z3_context c, Z3_ast rm, Z3_ast exp, Z3_ast sig, Z3_sort s) {
Z3_TRY;
LOG_Z3_mk_fpa_to_fp_int_real(c, rm, sig, exp, s);
RESET_ERROR_CODE();
api::context * ctx = mk_c(c);
fpa_util & fu = ctx->fpautil();
if (!fu.is_rm(to_expr(rm)) ||
!ctx->autil().is_real(to_expr(sig)) ||
!ctx->autil().is_int(to_expr(exp)) ||
!fu.is_float(to_sort(s))) {
SET_ERROR_CODE(Z3_INVALID_ARG);
return 0;
}
expr * a = fu.mk_to_fp(to_sort(s), to_expr(rm), to_expr(sig), to_expr(exp));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(0);
}
};

View file

@ -1,20 +1,20 @@
/*++
Copyright (c) 2011 Microsoft Corporation
Copyright (c) 2011 Microsoft Corporation
Module Name:
Module Name:
api_interp.cpp
api_interp.cpp
Abstract:
API for interpolation
Abstract:
API for interpolation
Author:
Author:
Ken McMillan
Ken McMillan
Revision History:
Revision History:
--*/
--*/
#include<iostream>
#include<sstream>
#include<vector>
@ -66,7 +66,6 @@ extern "C" {
// Z3_set_param_value(cfg, "SIMPLIFY_CLAUSES","false");
Z3_context ctx = Z3_mk_context(cfg);
Z3_del_config(cfg);
return ctx;
}
@ -192,19 +191,19 @@ extern "C" {
Z3_interpolation_options
Z3_mk_interpolation_options(){
Z3_mk_interpolation_options(){
return (Z3_interpolation_options) new interpolation_options_struct;
}
void
Z3_del_interpolation_options(Z3_interpolation_options opts){
Z3_del_interpolation_options(Z3_interpolation_options opts){
delete opts;
}
void
Z3_set_interpolation_option(Z3_interpolation_options opts,
Z3_string name,
Z3_string value){
Z3_set_interpolation_option(Z3_interpolation_options opts,
Z3_string name,
Z3_string value){
opts->map[name] = value;
}
@ -293,10 +292,10 @@ extern "C" {
else {
model_ref _m;
m_solver.get()->get_model(_m);
Z3_model_ref *crap = alloc(Z3_model_ref);
crap->m_model = _m.get();
mk_c(c)->save_object(crap);
*model = of_model(crap);
Z3_model_ref *tmp_val = alloc(Z3_model_ref);
tmp_val->m_model = _m.get();
mk_c(c)->save_object(tmp_val);
*model = of_model(tmp_val);
}
*out_interp = of_ast_vector(v);
@ -413,11 +412,11 @@ extern "C" {
Z3_ast foo = Z3_mk_interpolant(ctx, and_vec(ctx, c));
chs[parents[i]].push_back(foo);
}
{
svector<Z3_ast> &c = chs[num - 1];
c.push_back(cnsts[num - 1]);
res = and_vec(ctx, c);
}
{
svector<Z3_ast> &c = chs[num - 1];
c.push_back(cnsts[num - 1]);
res = and_vec(ctx, c);
}
}
Z3_inc_ref(ctx, res);
return res;
@ -490,8 +489,8 @@ extern "C" {
try {
std::string foo(filename);
if (foo.size() >= 5 && foo.substr(foo.size() - 5) == ".smt2"){
Z3_ast ass = Z3_parse_smtlib2_file(ctx, filename, 0, 0, 0, 0, 0, 0);
Z3_app app = Z3_to_app(ctx, ass);
Z3_ast assrts = Z3_parse_smtlib2_file(ctx, filename, 0, 0, 0, 0, 0, 0);
Z3_app app = Z3_to_app(ctx, assrts);
int nconjs = Z3_get_app_num_args(ctx, app);
assertions.resize(nconjs);
for (int k = 0; k < nconjs; k++)
@ -621,8 +620,8 @@ extern "C" {
for (unsigned j = 0; j < num - 1; j++)
if (read_parents[j] == SHRT_MAX){
read_error << "formula " << j + 1 << ": unreferenced";
goto fail;
read_error << "formula " << j + 1 << ": unreferenced";
goto fail;
}
*_num = num;
@ -644,69 +643,69 @@ extern "C" {
#define IZ3_ROOT SHRT_MAX
/** This function uses Z3 to determine satisfiability of a set of
constraints. If UNSAT, an interpolant is returned, based on the
refutation generated by Z3. If SAT, a model is returned.
constraints. If UNSAT, an interpolant is returned, based on the
refutation generated by Z3. If SAT, a model is returned.
If "parents" is non-null, computes a tree interpolant. The tree is
defined by the array "parents". This array maps each formula in
the tree to its parent, where formulas are indicated by their
integer index in "cnsts". The parent of formula n must have index
greater than n. The last formula is the root of the tree. Its
parent entry should be the constant IZ3_ROOT.
If "parents" is non-null, computes a tree interpolant. The tree is
defined by the array "parents". This array maps each formula in
the tree to its parent, where formulas are indicated by their
integer index in "cnsts". The parent of formula n must have index
greater than n. The last formula is the root of the tree. Its
parent entry should be the constant IZ3_ROOT.
If "parents" is null, computes a sequence interpolant.
If "parents" is null, computes a sequence interpolant.
\param ctx The Z3 context. Must be generated by iz3_mk_context
\param num The number of constraints in the sequence
\param cnsts Array of constraints (AST's in context ctx)
\param parents The parents vector defining the tree structure
\param options Interpolation options (may be NULL)
\param interps Array to return interpolants (size at least num-1, may be NULL)
\param model Returns a Z3 model if constraints SAT (may be NULL)
\param labels Returns relevant labels if SAT (may be NULL)
\param incremental
\param ctx The Z3 context. Must be generated by iz3_mk_context
\param num The number of constraints in the sequence
\param cnsts Array of constraints (AST's in context ctx)
\param parents The parents vector defining the tree structure
\param options Interpolation options (may be NULL)
\param interps Array to return interpolants (size at least num-1, may be NULL)
\param model Returns a Z3 model if constraints SAT (may be NULL)
\param labels Returns relevant labels if SAT (may be NULL)
\param incremental
VERY IMPORTANT: All the Z3 formulas in cnsts must be in Z3
context ctx. The model and interpolants returned are also
in this context.
VERY IMPORTANT: All the Z3 formulas in cnsts must be in Z3
context ctx. The model and interpolants returned are also
in this context.
The return code is as in Z3_check_assumptions, that is,
The return code is as in Z3_check_assumptions, that is,
Z3_L_FALSE = constraints UNSAT (interpolants returned)
Z3_L_TRUE = constraints SAT (model returned)
Z3_L_UNDEF = Z3 produced no result, or interpolation not possible
Z3_L_FALSE = constraints UNSAT (interpolants returned)
Z3_L_TRUE = constraints SAT (model returned)
Z3_L_UNDEF = Z3 produced no result, or interpolation not possible
Currently, this function supports integer and boolean variables,
as well as arrays over these types, with linear arithmetic,
uninterpreted functions and quantifiers over integers (that is
AUFLIA). Interpolants are produced in AULIA. However, some
uses of array operations may cause quantifiers to appear in the
interpolants even when there are no quantifiers in the input formulas.
Although quantifiers may appear in the input formulas, Z3 may give up in
this case, returning Z3_L_UNDEF.
Currently, this function supports integer and boolean variables,
as well as arrays over these types, with linear arithmetic,
uninterpreted functions and quantifiers over integers (that is
AUFLIA). Interpolants are produced in AULIA. However, some
uses of array operations may cause quantifiers to appear in the
interpolants even when there are no quantifiers in the input formulas.
Although quantifiers may appear in the input formulas, Z3 may give up in
this case, returning Z3_L_UNDEF.
If "incremental" is true, cnsts must contain exactly the set of
formulas that are currently asserted in the context. If false,
there must be no formulas currently asserted in the context.
Setting "incremental" to true makes it posisble to incrementally
add and remove constraints from the context until the context
becomes UNSAT, at which point an interpolant is computed. Caution
must be used, however. Before popping the context, if you wish to
keep the interolant formulas, you *must* preserve them by using
Z3_persist_ast. Also, if you want to simplify the interpolant
formulas using Z3_simplify, you must first pop all of the
assertions in the context (or use a different context). Otherwise,
the formulas will be simplified *relative* to these constraints,
which is almost certainly not what you want.
If "incremental" is true, cnsts must contain exactly the set of
formulas that are currently asserted in the context. If false,
there must be no formulas currently asserted in the context.
Setting "incremental" to true makes it posisble to incrementally
add and remove constraints from the context until the context
becomes UNSAT, at which point an interpolant is computed. Caution
must be used, however. Before popping the context, if you wish to
keep the interolant formulas, you *must* preserve them by using
Z3_persist_ast. Also, if you want to simplify the interpolant
formulas using Z3_simplify, you must first pop all of the
assertions in the context (or use a different context). Otherwise,
the formulas will be simplified *relative* to these constraints,
which is almost certainly not what you want.
Current limitations on tree interpolants. In a tree interpolation
problem, each constant (0-ary function symbol) must occur only
along one path from root to leaf. Function symbols (of arity > 0)
are considered to have global scope (i.e., may appear in any
interpolant formula).
Current limitations on tree interpolants. In a tree interpolation
problem, each constant (0-ary function symbol) must occur only
along one path from root to leaf. Function symbols (of arity > 0)
are considered to have global scope (i.e., may appear in any
interpolant formula).
def_API('Z3_interpolate', BOOL, (_in(CONTEXT), _in(UINT), _in_array(1, AST), _in_array(1, UINT), _in(PARAMS), _out_array(1, AST), _out(MODEL), _out(LITERALS), _in(UINT), _in(UINT), _in_array(9, AST)))
def_API('Z3_interpolate', BOOL, (_in(CONTEXT), _in(UINT), _in_array(1, AST), _in_array(1, UINT), _in(PARAMS), _out_array(1, AST), _out(MODEL), _out(LITERALS), _in(UINT), _in(UINT), _in_array(9, AST)))
*/
Z3_lbool Z3_API Z3_interpolate(__in Z3_context ctx,

View file

@ -663,7 +663,7 @@ extern "C" {
Z3_CATCH_RETURN(Z3_FALSE);
}
char const * Z3_API Z3_model_to_string(Z3_context c, Z3_model m) {
Z3_API char const * Z3_model_to_string(Z3_context c, Z3_model m) {
Z3_TRY;
LOG_Z3_model_to_string(c, m);
RESET_ERROR_CODE();

View file

@ -23,13 +23,15 @@ Revision History:
#include"arith_decl_plugin.h"
#include"bv_decl_plugin.h"
#include"algebraic_numbers.h"
#include"fpa_decl_plugin.h"
bool is_numeral_sort(Z3_context c, Z3_sort ty) {
sort * _ty = to_sort(ty);
family_id fid = _ty->get_family_id();
if (fid != mk_c(c)->get_arith_fid() &&
fid != mk_c(c)->get_bv_fid() &&
fid != mk_c(c)->get_datalog_fid()) {
fid != mk_c(c)->get_datalog_fid() &&
fid != mk_c(c)->get_fpa_fid()) {
return false;
}
return true;
@ -48,7 +50,7 @@ extern "C" {
Z3_ast Z3_API Z3_mk_numeral(Z3_context c, const char* n, Z3_sort ty) {
Z3_TRY;
LOG_Z3_mk_numeral(c, n, ty);
RESET_ERROR_CODE();
RESET_ERROR_CODE();
if (!check_numeral_sort(c, ty)) {
RETURN_Z3(0);
}
@ -56,40 +58,42 @@ extern "C" {
SET_ERROR_CODE(Z3_INVALID_ARG);
RETURN_Z3(0);
}
sort * _ty = to_sort(ty);
bool is_float = mk_c(c)->fpautil().is_float(_ty);
std::string fixed_num;
char const* m = n;
while (*m) {
if (!(('0' <= *m && *m <= '9') ||
('/' == *m) || ('-' == *m) ||
(' ' == *m) || ('\n' == *m) ||
('.' == *m) || ('e' == *m) ||
('E' == *m))) {
('/' == *m) || ('-' == *m) ||
(' ' == *m) || ('\n' == *m) ||
('.' == *m) || ('e' == *m) ||
('E' == *m) ||
('p' == *m && is_float) ||
('P' == *m && is_float))) {
SET_ERROR_CODE(Z3_PARSER_ERROR);
return 0;
}
++m;
}
ast * a = mk_c(c)->mk_numeral_core(rational(n), to_sort(ty));
ast * a = 0;
if (_ty->get_family_id() == mk_c(c)->get_fpa_fid()) {
// avoid expanding floats into huge rationals.
fpa_util & fu = mk_c(c)->fpautil();
scoped_mpf t(fu.fm());
fu.fm().set(t, fu.get_ebits(_ty), fu.get_sbits(_ty), MPF_ROUND_TOWARD_ZERO, n);
a = fu.mk_value(t);
mk_c(c)->save_ast_trail(a);
}
else
a = mk_c(c)->mk_numeral_core(rational(n), _ty);
RETURN_Z3(of_ast(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_int(Z3_context c, int value, Z3_sort ty) {
Z3_TRY;
LOG_Z3_mk_int(c, value, ty);
RESET_ERROR_CODE();
if (!check_numeral_sort(c, ty)) {
RETURN_Z3(0);
}
ast * a = mk_c(c)->mk_numeral_core(rational(value), to_sort(ty));
RETURN_Z3(of_ast(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_unsigned_int(Z3_context c, unsigned value, Z3_sort ty) {
Z3_TRY;
LOG_Z3_mk_unsigned_int(c, value, ty);
RESET_ERROR_CODE();
RESET_ERROR_CODE();
if (!check_numeral_sort(c, ty)) {
RETURN_Z3(0);
}
@ -97,11 +101,23 @@ extern "C" {
RETURN_Z3(of_ast(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_unsigned_int(Z3_context c, unsigned value, Z3_sort ty) {
Z3_TRY;
LOG_Z3_mk_unsigned_int(c, value, ty);
RESET_ERROR_CODE();
if (!check_numeral_sort(c, ty)) {
RETURN_Z3(0);
}
ast * a = mk_c(c)->mk_numeral_core(rational(value), to_sort(ty));
RETURN_Z3(of_ast(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_int64(Z3_context c, long long value, Z3_sort ty) {
Z3_TRY;
LOG_Z3_mk_int64(c, value, ty);
RESET_ERROR_CODE();
RESET_ERROR_CODE();
if (!check_numeral_sort(c, ty)) {
RETURN_Z3(0);
}
@ -110,11 +126,11 @@ extern "C" {
RETURN_Z3(of_ast(a));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_API Z3_mk_unsigned_int64(Z3_context c, unsigned long long value, Z3_sort ty) {
Z3_TRY;
LOG_Z3_mk_unsigned_int64(c, value, ty);
RESET_ERROR_CODE();
RESET_ERROR_CODE();
if (!check_numeral_sort(c, ty)) {
RETURN_Z3(0);
}
@ -129,9 +145,11 @@ extern "C" {
LOG_Z3_is_numeral_ast(c, a);
RESET_ERROR_CODE();
expr* e = to_expr(a);
return
return
mk_c(c)->autil().is_numeral(e) ||
mk_c(c)->bvutil().is_numeral(e);
mk_c(c)->bvutil().is_numeral(e) ||
mk_c(c)->fpautil().is_numeral(e) ||
mk_c(c)->fpautil().is_rm_numeral(e);
Z3_CATCH_RETURN(Z3_FALSE);
}
@ -172,8 +190,37 @@ extern "C" {
return mk_c(c)->mk_external_string(r.to_string());
}
else {
SET_ERROR_CODE(Z3_INVALID_ARG);
return "";
// floats are separated from all others to avoid huge rationals.
fpa_util & fu = mk_c(c)->fpautil();
scoped_mpf tmp(fu.fm());
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:
return mk_c(c)->mk_external_string("roundNearestTiesToEven");
break;
case OP_FPA_RM_NEAREST_TIES_TO_AWAY:
return mk_c(c)->mk_external_string("roundNearestTiesToAway");
break;
case OP_FPA_RM_TOWARD_POSITIVE:
return mk_c(c)->mk_external_string("roundTowardPositive");
break;
case OP_FPA_RM_TOWARD_NEGATIVE:
return mk_c(c)->mk_external_string("roundTowardNegative");
break;
case OP_FPA_RM_TOWARD_ZERO:
default:
return mk_c(c)->mk_external_string("roundTowardZero");
break;
}
}
else if (mk_c(c)->fpautil().is_numeral(to_expr(a), tmp)) {
return mk_c(c)->mk_external_string(fu.fm().to_string(tmp));
}
else {
SET_ERROR_CODE(Z3_INVALID_ARG);
return "";
}
}
Z3_CATCH_RETURN("");
}

View file

@ -507,7 +507,7 @@ extern "C" {
return (Z3_ast)(p);
}
char const * Z3_API Z3_pattern_to_string(Z3_context c, Z3_pattern p) {
Z3_API char const * Z3_pattern_to_string(Z3_context c, Z3_pattern p) {
return Z3_ast_to_string(c, reinterpret_cast<Z3_ast>(p));
}

View file

@ -297,7 +297,7 @@ extern "C" {
Z3_CATCH;
}
char const * Z3_API Z3_context_to_string(Z3_context c) {
Z3_API char const * Z3_context_to_string(Z3_context c) {
Z3_TRY;
LOG_Z3_context_to_string(c);
RESET_ERROR_CODE();

View file

@ -866,6 +866,9 @@ namespace z3 {
friend expr operator|(int a, expr const & b) { return b.ctx().num_val(a, b.get_sort()) | b; }
friend expr operator~(expr const & a) { Z3_ast r = Z3_mk_bvnot(a.ctx(), a); return expr(a.ctx(), r); }
expr extract(unsigned hi, unsigned lo) const { Z3_ast r = Z3_mk_extract(ctx(), hi, lo, *this); return expr(ctx(), r); }
unsigned lo() const { assert (is_app() && Z3_get_decl_num_parameters(ctx(), decl()) == 2); return static_cast<unsigned>(Z3_get_decl_int_parameter(ctx(), decl(), 1)); }
unsigned hi() const { assert (is_app() && Z3_get_decl_num_parameters(ctx(), decl()) == 2); return static_cast<unsigned>(Z3_get_decl_int_parameter(ctx(), decl(), 0)); }
/**
\brief Return a simplified version of this expression.
@ -1314,6 +1317,26 @@ namespace z3 {
expr_vector assertions() const { Z3_ast_vector r = Z3_solver_get_assertions(ctx(), m_solver); check_error(); return expr_vector(ctx(), r); }
expr proof() const { Z3_ast r = Z3_solver_get_proof(ctx(), m_solver); check_error(); return expr(ctx(), r); }
friend std::ostream & operator<<(std::ostream & out, solver const & s) { out << Z3_solver_to_string(s.ctx(), s); return out; }
std::string to_smt2(char const* status = "unknown") {
array<Z3_ast> es(assertions());
Z3_ast const* fmls = es.ptr();
Z3_ast fml = 0;
unsigned sz = es.size();
if (sz > 0) {
--sz;
fml = fmls[sz];
}
else {
fml = ctx().bool_val(true);
}
return std::string(Z3_benchmark_to_smtlib_string(
ctx(),
"", "", status, "",
sz,
fmls,
fml));
}
};
class goal : public object {

View file

@ -213,12 +213,14 @@ namespace Microsoft.Z3
internal class DecRefQueue : IDecRefQueue
{
public override void IncRef(Context ctx, IntPtr obj)
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_dec_ref(ctx.nCtx, obj);
}
@ -227,10 +229,8 @@ namespace Microsoft.Z3
internal override void IncRef(IntPtr o)
{
// Console.WriteLine("AST IncRef()");
if (Context == null)
throw new Z3Exception("inc() called on null context");
if (o == IntPtr.Zero)
throw new Z3Exception("inc() called on null AST");
if (Context == null || o == IntPtr.Zero)
return;
Context.AST_DRQ.IncAndClear(Context, o);
base.IncRef(o);
}
@ -238,10 +238,8 @@ namespace Microsoft.Z3
internal override void DecRef(IntPtr o)
{
// Console.WriteLine("AST DecRef()");
if (Context == null)
throw new Z3Exception("dec() called on null context");
if (o == IntPtr.Zero)
throw new Z3Exception("dec() called on null AST");
if (Context == null || o == IntPtr.Zero)
return;
Context.AST_DRQ.Add(o);
base.DecRef(o);
}

View file

@ -128,12 +128,14 @@ namespace Microsoft.Z3
internal class DecRefQueue : IDecRefQueue
{
public override void IncRef(Context ctx, IntPtr obj)
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_ast_map_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_ast_map_dec_ref(ctx.nCtx, obj);
}

View file

@ -25,7 +25,7 @@ namespace Microsoft.Z3
/// <summary>
/// Vectors of ASTs.
/// </summary>
internal class ASTVector : Z3Object
public class ASTVector : Z3Object
{
/// <summary>
/// The size of the vector
@ -105,12 +105,14 @@ namespace Microsoft.Z3
internal class DecRefQueue : IDecRefQueue
{
public override void IncRef(Context ctx, IntPtr obj)
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_ast_vector_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_ast_vector_dec_ref(ctx.nCtx, obj);
}

View file

@ -85,12 +85,14 @@ namespace Microsoft.Z3
internal class DecRefQueue : IDecRefQueue
{
public override void IncRef(Context ctx, IntPtr obj)
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_apply_result_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_apply_result_dec_ref(ctx.nCtx, obj);
}

View file

@ -32,11 +32,6 @@ namespace Microsoft.Z3
{
#region Internal
/// <summary> Constructor for ArithExpr </summary>
internal protected ArithExpr(Context ctx)
: base(ctx)
{
Contract.Requires(ctx != null);
}
internal ArithExpr(Context ctx, IntPtr obj)
: base(ctx, obj)
{

View file

@ -32,11 +32,6 @@ namespace Microsoft.Z3
{
#region Internal
/// <summary> Constructor for ArrayExpr </summary>
internal protected ArrayExpr(Context ctx)
: base(ctx)
{
Contract.Requires(ctx != null);
}
internal ArrayExpr(Context ctx, IntPtr obj)
: base(ctx, obj)
{

View file

@ -41,7 +41,6 @@ namespace Microsoft.Z3
#region Internal
/// <summary> Constructor for BitVecExpr </summary>
internal protected BitVecExpr(Context ctx) : base(ctx) { Contract.Requires(ctx != null); }
internal BitVecExpr(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
#endregion
}

View file

@ -32,8 +32,6 @@ namespace Microsoft.Z3
{
#region Internal
/// <summary> Constructor for BoolExpr </summary>
internal protected BoolExpr(Context ctx) : base(ctx) { Contract.Requires(ctx != null); }
/// <summary> Constructor for BoolExpr </summary>
internal BoolExpr(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
#endregion
}

View file

@ -2516,7 +2516,7 @@ namespace Microsoft.Z3
/// Create a bit-vector numeral.
/// </summary>
/// <param name="v">value of the numeral.</param>
/// /// <param name="size">the size of the bit-vector</param>
/// <param name="size">the size of the bit-vector</param>
public BitVecNum MkBV(long v, uint size)
{
Contract.Ensures(Contract.Result<BitVecNum>() != null);
@ -3438,6 +3438,805 @@ namespace Microsoft.Z3
}
#endregion
#region Floating-Point Arithmetic
#region Rounding Modes
#region RoundingMode Sort
/// <summary>
/// Create the floating-point RoundingMode sort.
/// </summary>
public FPRMSort MkFPRoundingModeSort()
{
Contract.Ensures(Contract.Result<FPRMSort>() != null);
return new FPRMSort(this);
}
#endregion
#region Numerals
/// <summary>
/// Create a numeral of RoundingMode sort which represents the NearestTiesToEven rounding mode.
/// </summary>
public FPRMExpr MkFPRoundNearestTiesToEven()
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPRMExpr(this, Native.Z3_mk_fpa_round_nearest_ties_to_even(nCtx));
}
/// <summary>
/// Create a numeral of RoundingMode sort which represents the NearestTiesToEven rounding mode.
/// </summary>
public FPRMNum MkFPRNE()
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPRMNum(this, Native.Z3_mk_fpa_rne(nCtx));
}
/// <summary>
/// Create a numeral of RoundingMode sort which represents the NearestTiesToAway rounding mode.
/// </summary>
public FPRMNum MkFPRoundNearestTiesToAway()
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPRMNum(this, Native.Z3_mk_fpa_round_nearest_ties_to_away(nCtx));
}
/// <summary>
/// Create a numeral of RoundingMode sort which represents the NearestTiesToAway rounding mode.
/// </summary>
public FPRMNum MkFPRNA()
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPRMNum(this, Native.Z3_mk_fpa_rna(nCtx));
}
/// <summary>
/// Create a numeral of RoundingMode sort which represents the RoundTowardPositive rounding mode.
/// </summary>
public FPRMNum MkFPRoundTowardPositive()
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPRMNum(this, Native.Z3_mk_fpa_round_toward_positive(nCtx));
}
/// <summary>
/// Create a numeral of RoundingMode sort which represents the RoundTowardPositive rounding mode.
/// </summary>
public FPRMNum MkFPRTP()
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPRMNum(this, Native.Z3_mk_fpa_rtp(nCtx));
}
/// <summary>
/// Create a numeral of RoundingMode sort which represents the RoundTowardNegative rounding mode.
/// </summary>
public FPRMNum MkFPRoundTowardNegative()
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPRMNum(this, Native.Z3_mk_fpa_round_toward_negative(nCtx));
}
/// <summary>
/// Create a numeral of RoundingMode sort which represents the RoundTowardNegative rounding mode.
/// </summary>
public FPRMNum MkFPRTN()
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPRMNum(this, Native.Z3_mk_fpa_rtn(nCtx));
}
/// <summary>
/// Create a numeral of RoundingMode sort which represents the RoundTowardZero rounding mode.
/// </summary>
public FPRMNum MkFPRoundTowardZero()
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPRMNum(this, Native.Z3_mk_fpa_round_toward_zero(nCtx));
}
/// <summary>
/// Create a numeral of RoundingMode sort which represents the RoundTowardZero rounding mode.
/// </summary>
public FPRMNum MkFPRTZ()
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPRMNum(this, Native.Z3_mk_fpa_rtz(nCtx));
}
#endregion
#endregion
#region FloatingPoint Sorts
/// <summary>
/// Create a FloatingPoint sort.
/// </summary>
/// <param name="ebits">exponent bits in the FloatingPoint sort.</param>
/// <param name="sbits">significand bits in the FloatingPoint sort.</param>
public FPSort MkFPSort(uint ebits, uint sbits)
{
Contract.Ensures(Contract.Result<FPSort>() != null);
return new FPSort(this, ebits, sbits);
}
/// <summary>
/// Create the half-precision (16-bit) FloatingPoint sort.
/// </summary>
public FPSort MkFPSortHalf()
{
Contract.Ensures(Contract.Result<FPSort>() != null);
return new FPSort(this, Native.Z3_mk_fpa_sort_half(nCtx));
}
/// <summary>
/// Create the half-precision (16-bit) FloatingPoint sort.
/// </summary>
public FPSort MkFPSort16()
{
Contract.Ensures(Contract.Result<FPSort>() != null);
return new FPSort(this, Native.Z3_mk_fpa_sort_16(nCtx));
}
/// <summary>
/// Create the single-precision (32-bit) FloatingPoint sort.
/// </summary>
public FPSort MkFPSortSingle()
{
Contract.Ensures(Contract.Result<FPSort>() != null);
return new FPSort(this, Native.Z3_mk_fpa_sort_single(nCtx));
}
/// <summary>
/// Create the single-precision (32-bit) FloatingPoint sort.
/// </summary>
public FPSort MkFPSort32()
{
Contract.Ensures(Contract.Result<FPSort>() != null);
return new FPSort(this, Native.Z3_mk_fpa_sort_32(nCtx));
}
/// <summary>
/// Create the double-precision (64-bit) FloatingPoint sort.
/// </summary>
public FPSort MkFPSortDouble()
{
Contract.Ensures(Contract.Result<FPSort>() != null);
return new FPSort(this, Native.Z3_mk_fpa_sort_double(nCtx));
}
/// <summary>
/// Create the double-precision (64-bit) FloatingPoint sort.
/// </summary>
public FPSort MkFPSort64()
{
Contract.Ensures(Contract.Result<FPSort>() != null);
return new FPSort(this, Native.Z3_mk_fpa_sort_64(nCtx));
}
/// <summary>
/// Create the quadruple-precision (128-bit) FloatingPoint sort.
/// </summary>
public FPSort MkFPSortQuadruple()
{
Contract.Ensures(Contract.Result<FPSort>() != null);
return new FPSort(this, Native.Z3_mk_fpa_sort_quadruple(nCtx));
}
/// <summary>
/// Create the quadruple-precision (128-bit) FloatingPoint sort.
/// </summary>
public FPSort MkFPSort128()
{
Contract.Ensures(Contract.Result<FPSort>() != null);
return new FPSort(this, Native.Z3_mk_fpa_sort_128(nCtx));
}
#endregion
#region Numerals
/// <summary>
/// Create a NaN of sort s.
/// </summary>
/// <param name="s">FloatingPoint sort.</param>
public FPNum MkFPNaN(FPSort s)
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPNum(this, Native.Z3_mk_fpa_nan(nCtx, s.NativeObject));
}
/// <summary>
/// Create a floating-point infinity of sort s.
/// </summary>
/// <param name="s">FloatingPoint sort.</param>
/// <param name="negative">indicates whether the result should be negative.</param>
public FPNum MkFPInf(FPSort s, bool negative)
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPNum(this, Native.Z3_mk_fpa_inf(nCtx, s.NativeObject, negative ? 1 : 0));
}
/// <summary>
/// Create a floating-point zero of sort s.
/// </summary>
/// <param name="s">FloatingPoint sort.</param>
/// <param name="negative">indicates whether the result should be negative.</param>
public FPNum MkFPZero(FPSort s, bool negative)
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPNum(this, Native.Z3_mk_fpa_zero(nCtx, s.NativeObject, negative ? 1 : 0));
}
/// <summary>
/// Create a numeral of FloatingPoint sort from a float.
/// </summary>
/// <param name="v">numeral value.</param>
/// <param name="s">FloatingPoint sort.</param>
public FPNum MkFPNumeral(float v, FPSort s)
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPNum(this, Native.Z3_mk_fpa_numeral_float(nCtx, v, s.NativeObject));
}
/// <summary>
/// Create a numeral of FloatingPoint sort from a float.
/// </summary>
/// <param name="v">numeral value.</param>
/// <param name="s">FloatingPoint sort.</param>
public FPNum MkFPNumeral(double v, FPSort s)
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPNum(this, Native.Z3_mk_fpa_numeral_double(nCtx, v, s.NativeObject));
}
/// <summary>
/// Create a numeral of FloatingPoint sort from an int.
/// </summary>
/// <param name="v">numeral value.</param>
/// <param name="s">FloatingPoint sort.</param>
public FPNum MkFPNumeral(int v, FPSort s)
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPNum(this, Native.Z3_mk_fpa_numeral_int(nCtx, v, s.NativeObject));
}
/// <summary>
/// Create a numeral of FloatingPoint sort from a sign bit and two integers.
/// </summary>
/// <param name="sgn">the sign.</param>
/// <param name="sig">the significand.</param>
/// <param name="exp">the exponent.</param>
/// <param name="s">FloatingPoint sort.</param>
public FPNum MkFPNumeral(bool sgn, uint sig, int exp, FPSort s)
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPNum(this, Native.Z3_mk_fpa_numeral_int_uint(nCtx, sgn ? 1 : 0, exp, sig, s.NativeObject));
}
/// <summary>
/// Create a numeral of FloatingPoint sort from a sign bit and two 64-bit integers.
/// </summary>
/// <param name="sgn">the sign.</param>
/// <param name="sig">the significand.</param>
/// <param name="exp">the exponent.</param>
/// <param name="s">FloatingPoint sort.</param>
public FPNum MkFPNumeral(bool sgn, Int64 exp, UInt64 sig, FPSort s)
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return new FPNum(this, Native.Z3_mk_fpa_numeral_int64_uint64(nCtx, sgn ? 1 : 0, exp, sig, s.NativeObject));
}
/// <summary>
/// Create a numeral of FloatingPoint sort from a float.
/// </summary>
/// <param name="v">numeral value.</param>
/// <param name="s">FloatingPoint sort.</param>
public FPNum MkFP(float v, FPSort s)
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return MkFPNumeral(v, s);
}
/// <summary>
/// Create a numeral of FloatingPoint sort from a float.
/// </summary>
/// <param name="v">numeral value.</param>
/// <param name="s">FloatingPoint sort.</param>
public FPNum MkFP(double v, FPSort s)
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return MkFPNumeral(v, s);
}
/// <summary>
/// Create a numeral of FloatingPoint sort from an int.
/// </summary>
/// <param name="v">numeral value.</param>
/// <param name="s">FloatingPoint sort.</param>
public FPNum MkFP(int v, FPSort s)
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return MkFPNumeral(v, s);
}
/// <summary>
/// Create a numeral of FloatingPoint sort from a sign bit and two integers.
/// </summary>
/// <param name="sgn">the sign.</param>
/// <param name="exp">the exponent.</param>
/// <param name="sig">the significand.</param>
/// <param name="s">FloatingPoint sort.</param>
public FPNum MkFP(bool sgn, int exp, uint sig, FPSort s)
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return MkFPNumeral(sgn, exp, sig, s);
}
/// <summary>
/// Create a numeral of FloatingPoint sort from a sign bit and two 64-bit integers.
/// </summary>
/// <param name="sgn">the sign.</param>
/// <param name="exp">the exponent.</param>
/// <param name="sig">the significand.</param>
/// <param name="s">FloatingPoint sort.</param>
public FPNum MkFP(bool sgn, Int64 exp, UInt64 sig, FPSort s)
{
Contract.Ensures(Contract.Result<FPRMExpr>() != null);
return MkFPNumeral(sgn, exp, sig, s);
}
#endregion
#region Operators
/// <summary>
/// Floating-point absolute value
/// </summary>
/// <param name="t">floating-point term</param>
public FPExpr MkFPAbs(FPExpr t)
{
Contract.Ensures(Contract.Result<FPNum>() != null);
return new FPExpr(this, Native.Z3_mk_fpa_abs(this.nCtx, t.NativeObject));
}
/// <summary>
/// Floating-point negation
/// </summary>
/// <param name="t">floating-point term</param>
public FPExpr MkFPNeg(FPExpr t)
{
Contract.Ensures(Contract.Result<FPNum>() != null);
return new FPExpr(this, Native.Z3_mk_fpa_neg(this.nCtx, t.NativeObject));
}
/// <summary>
/// Floating-point addition
/// </summary>
/// <param name="rm">rounding mode term</param>
/// <param name="t1">floating-point term</param>
/// <param name="t2">floating-point term</param>
public FPExpr MkFPAdd(FPRMExpr rm, FPExpr t1, FPExpr t2)
{
Contract.Ensures(Contract.Result<FPNum>() != null);
return new FPExpr(this, Native.Z3_mk_fpa_add(this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject));
}
/// <summary>
/// Floating-point subtraction
/// </summary>
/// <param name="rm">rounding mode term</param>
/// <param name="t1">floating-point term</param>
/// <param name="t2">floating-point term</param>
public FPExpr MkFPSub(FPRMExpr rm, FPExpr t1, FPExpr t2)
{
Contract.Ensures(Contract.Result<FPNum>() != null);
return new FPExpr(this, Native.Z3_mk_fpa_sub(this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject));
}
/// <summary>
/// Floating-point multiplication
/// </summary>
/// <param name="rm">rounding mode term</param>
/// <param name="t1">floating-point term</param>
/// <param name="t2">floating-point term</param>
public FPExpr MkFPMul(FPRMExpr rm, FPExpr t1, FPExpr t2)
{
Contract.Ensures(Contract.Result<FPNum>() != null);
return new FPExpr(this, Native.Z3_mk_fpa_mul(this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject));
}
/// <summary>
/// Floating-point division
/// </summary>
/// <param name="rm">rounding mode term</param>
/// <param name="t1">floating-point term</param>
/// <param name="t2">floating-point term</param>
public FPExpr MkFPDiv(FPRMExpr rm, FPExpr t1, FPExpr t2)
{
Contract.Ensures(Contract.Result<FPNum>() != null);
return new FPExpr(this, Native.Z3_mk_fpa_div(this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject));
}
/// <summary>
/// Floating-point fused multiply-add
/// </summary>
/// <remarks>
/// The result is round((t1 * t2) + t3)
/// </remarks>
/// <param name="rm">rounding mode term</param>
/// <param name="t1">floating-point term</param>
/// <param name="t2">floating-point term</param>
/// <param name="t3">floating-point term</param>
public FPExpr MkFPFMA(FPRMExpr rm, FPExpr t1, FPExpr t2, FPExpr t3)
{
Contract.Ensures(Contract.Result<FPNum>() != null);
return new FPExpr(this, Native.Z3_mk_fpa_fma(this.nCtx, rm.NativeObject, t1.NativeObject, t2.NativeObject, t3.NativeObject));
}
/// <summary>
/// Floating-point square root
/// </summary>
/// <param name="rm">rounding mode term</param>
/// <param name="t">floating-point term</param>
public FPExpr MkFPSqrt(FPRMExpr rm, FPExpr t)
{
Contract.Ensures(Contract.Result<FPNum>() != null);
return new FPExpr(this, Native.Z3_mk_fpa_sqrt(this.nCtx, rm.NativeObject, t.NativeObject));
}
/// <summary>
/// Floating-point remainder
/// </summary>
/// <param name="t1">floating-point term</param>
/// <param name="t2">floating-point term</param>
public FPExpr MkFPRem(FPExpr t1, FPExpr t2)
{
Contract.Ensures(Contract.Result<FPNum>() != null);
return new FPExpr(this, Native.Z3_mk_fpa_rem(this.nCtx, t1.NativeObject, t2.NativeObject));
}
/// <summary>
/// Floating-point roundToIntegral. Rounds a floating-point number to
/// the closest integer, again represented as a floating-point number.
/// </summary>
/// <param name="rm">term of RoundingMode sort</param>
/// <param name="t">floating-point term</param>
public FPExpr MkFPRoundToIntegral(FPRMExpr rm, FPExpr t)
{
Contract.Ensures(Contract.Result<FPNum>() != null);
return new FPExpr(this, Native.Z3_mk_fpa_round_to_integral(this.nCtx, rm.NativeObject, t.NativeObject));
}
/// <summary>
/// Minimum of floating-point numbers.
/// </summary>
/// <param name="t1">floating-point term</param>
/// <param name="t2">floating-point term</param>
public FPExpr MkFPMin(FPExpr t1, FPExpr t2)
{
Contract.Ensures(Contract.Result<FPNum>() != null);
return new FPExpr(this, Native.Z3_mk_fpa_min(this.nCtx, t1.NativeObject, t2.NativeObject));
}
/// <summary>
/// Maximum of floating-point numbers.
/// </summary>
/// <param name="t1">floating-point term</param>
/// <param name="t2">floating-point term</param>
public FPExpr MkFPMax(FPExpr t1, FPExpr t2)
{
Contract.Ensures(Contract.Result<FPNum>() != null);
return new FPExpr(this, Native.Z3_mk_fpa_max(this.nCtx, t1.NativeObject, t2.NativeObject));
}
/// <summary>
/// Floating-point less than or equal.
/// </summary>
/// <param name="t1">floating-point term</param>
/// <param name="t2">floating-point term</param>
public BoolExpr MkFPLEq(FPExpr t1, FPExpr t2)
{
Contract.Ensures(Contract.Result<BoolExpr>() != null);
return new BoolExpr(this, Native.Z3_mk_fpa_leq(this.nCtx, t1.NativeObject, t2.NativeObject));
}
/// <summary>
/// Floating-point less than.
/// </summary>
/// <param name="t1">floating-point term</param>
/// <param name="t2">floating-point term</param>
public BoolExpr MkFPLt(FPExpr t1, FPExpr t2)
{
Contract.Ensures(Contract.Result<BoolExpr>() != null);
return new BoolExpr(this, Native.Z3_mk_fpa_lt(this.nCtx, t1.NativeObject, t2.NativeObject));
}
/// <summary>
/// Floating-point greater than or equal.
/// </summary>
/// <param name="t1">floating-point term</param>
/// <param name="t2">floating-point term</param>
public BoolExpr MkFPGEq(FPExpr t1, FPExpr t2)
{
Contract.Ensures(Contract.Result<BoolExpr>() != null);
return new BoolExpr(this, Native.Z3_mk_fpa_geq(this.nCtx, t1.NativeObject, t2.NativeObject));
}
/// <summary>
/// Floating-point greater than.
/// </summary>
/// <param name="t1">floating-point term</param>
/// <param name="t2">floating-point term</param>
public BoolExpr MkFPGt(FPExpr t1, FPExpr t2)
{
Contract.Ensures(Contract.Result<BoolExpr>() != null);
return new BoolExpr(this, Native.Z3_mk_fpa_gt(this.nCtx, t1.NativeObject, t2.NativeObject));
}
/// <summary>
/// Floating-point equality.
/// </summary>
/// <remarks>
/// Note that this is IEEE 754 equality (as opposed to standard =).
/// </remarks>
/// <param name="t1">floating-point term</param>
/// <param name="t2">floating-point term</param>
public BoolExpr MkFPEq(FPExpr t1, FPExpr t2)
{
Contract.Ensures(Contract.Result<BoolExpr>() != null);
return new BoolExpr(this, Native.Z3_mk_fpa_eq(this.nCtx, t1.NativeObject, t2.NativeObject));
}
/// <summary>
/// Predicate indicating whether t is a normal floating-point number.
/// </summary>
/// <param name="t">floating-point term</param>
public BoolExpr MkFPIsNormal(FPExpr t)
{
Contract.Ensures(Contract.Result<BoolExpr>() != null);
return new BoolExpr(this, Native.Z3_mk_fpa_is_normal(this.nCtx, t.NativeObject));
}
/// <summary>
/// Predicate indicating whether t is a subnormal floating-point number.
/// </summary>
/// <param name="t">floating-point term</param>
public BoolExpr MkFPIsSubnormal(FPExpr t)
{
Contract.Ensures(Contract.Result<BoolExpr>() != null);
return new BoolExpr(this, Native.Z3_mk_fpa_is_subnormal(this.nCtx, t.NativeObject));
}
/// <summary>
/// Predicate indicating whether t is a floating-point number with zero value, i.e., +0 or -0.
/// </summary>
/// <param name="t">floating-point term</param>
public BoolExpr MkFPIsZero(FPExpr t)
{
Contract.Ensures(Contract.Result<BoolExpr>() != null);
return new BoolExpr(this, Native.Z3_mk_fpa_is_zero(this.nCtx, t.NativeObject));
}
/// <summary>
/// Predicate indicating whether t is a floating-point number representing +oo or -oo.
/// </summary>
/// <param name="t">floating-point term</param>
public BoolExpr MkFPIsInfinite(FPExpr t)
{
Contract.Ensures(Contract.Result<BoolExpr>() != null);
return new BoolExpr(this, Native.Z3_mk_fpa_is_infinite(this.nCtx, t.NativeObject));
}
/// <summary>
/// Predicate indicating whether t is a NaN.
/// </summary>
/// <param name="t">floating-point term</param>
public BoolExpr MkFPIsNaN(FPExpr t)
{
Contract.Ensures(Contract.Result<BoolExpr>() != null);
return new BoolExpr(this, Native.Z3_mk_fpa_is_nan(this.nCtx, t.NativeObject));
}
/// <summary>
/// Predicate indicating whether t is a negative floating-point number.
/// </summary>
/// <param name="t">floating-point term</param>
public BoolExpr MkFPIsNegative(FPExpr t)
{
Contract.Ensures(Contract.Result<BoolExpr>() != null);
return new BoolExpr(this, Native.Z3_mk_fpa_is_negative(this.nCtx, t.NativeObject));
}
/// <summary>
/// Predicate indicating whether t is a positive floating-point number.
/// </summary>
/// <param name="t">floating-point term</param>
public BoolExpr MkFPIsPositive(FPExpr t)
{
Contract.Ensures(Contract.Result<BoolExpr>() != null);
return new BoolExpr(this, Native.Z3_mk_fpa_is_positive(this.nCtx, t.NativeObject));
}
#endregion
#region Conversions to FloatingPoint terms
/// <summary>
/// Create an expression of FloatingPoint sort from three bit-vector expressions.
/// </summary>
/// <remarks>
/// This is the operator named `fp' in the SMT FP theory definition.
/// Note that sgn is required to be a bit-vector of size 1. Significand and exponent
/// are required to be greater than 1 and 2 respectively. The FloatingPoint sort
/// of the resulting expression is automatically determined from the bit-vector sizes
/// of the arguments.
/// </remarks>
/// <param name="sgn">bit-vector term (of size 1) representing the sign.</param>
/// <param name="sig">bit-vector term representing the significand.</param>
/// <param name="exp">bit-vector term representing the exponent.</param>
public FPExpr MkFP(BitVecExpr sgn, BitVecExpr sig, BitVecExpr exp)
{
Contract.Ensures(Contract.Result<FPExpr>() != null);
return new FPExpr(this, Native.Z3_mk_fpa_fp(this.nCtx, sgn.NativeObject, sig.NativeObject, exp.NativeObject));
}
/// <summary>
/// Conversion of a single IEEE 754-2008 bit-vector into a floating-point number.
/// </summary>
/// <remarks>
/// Produces a term that represents the conversion of a bit-vector term bv to a
/// floating-point term of sort s. The bit-vector size of bv (m) must be equal
/// to ebits+sbits of s. The format of the bit-vector is as defined by the
/// IEEE 754-2008 interchange format.
/// </remarks>
/// <param name="bv">bit-vector value (of size m).</param>
/// <param name="s">FloatingPoint sort (ebits+sbits == m)</param>
public FPExpr MkFPToFP(BitVecExpr bv, FPSort s)
{
Contract.Ensures(Contract.Result<FPExpr>() != null);
return new FPExpr(this, Native.Z3_mk_fpa_to_fp_bv(this.nCtx, bv.NativeObject, s.NativeObject));
}
/// <summary>
/// Conversion of a FloatingPoint term into another term of different FloatingPoint sort.
/// </summary>
/// <remarks>
/// Produces a term that represents the conversion of a floating-point term t to a
/// floating-point term of sort s. If necessary, the result will be rounded according
/// to rounding mode rm.
/// </remarks>
/// <param name="rm">RoundingMode term.</param>
/// <param name="t">FloatingPoint term.</param>
/// <param name="s">FloatingPoint sort.</param>
public FPExpr MkFPToFP(FPRMExpr rm, FPExpr t, FPSort s)
{
Contract.Ensures(Contract.Result<FPExpr>() != null);
return new FPExpr(this, Native.Z3_mk_fpa_to_fp_float(this.nCtx, rm.NativeObject, t.NativeObject, s.NativeObject));
}
/// <summary>
/// Conversion of a term of real sort into a term of FloatingPoint sort.
/// </summary>
/// <remarks>
/// Produces a term that represents the conversion of term t of real sort into a
/// floating-point term of sort s. If necessary, the result will be rounded according
/// to rounding mode rm.
/// </remarks>
/// <param name="rm">RoundingMode term.</param>
/// <param name="t">term of Real sort.</param>
/// <param name="s">FloatingPoint sort.</param>
public FPExpr MkFPToFP(FPRMExpr rm, RealExpr t, FPSort s)
{
Contract.Ensures(Contract.Result<FPExpr>() != null);
return new FPExpr(this, Native.Z3_mk_fpa_to_fp_real(this.nCtx, rm.NativeObject, t.NativeObject, s.NativeObject));
}
/// <summary>
/// Conversion of a 2's complement signed bit-vector term into a term of FloatingPoint sort.
/// </summary>
/// <remarks>
/// Produces a term that represents the conversion of the bit-vector term t into a
/// floating-point term of sort s. The bit-vector t is taken to be in signed
/// 2's complement format (when signed==true, otherwise unsigned). If necessary, the
/// result will be rounded according to rounding mode rm.
/// </remarks>
/// <param name="rm">RoundingMode term.</param>
/// <param name="t">term of bit-vector sort.</param>
/// <param name="s">FloatingPoint sort.</param>
/// <param name="signed">flag indicating whether t is interpreted as signed or unsigned bit-vector.</param>
public FPExpr MkFPToFP(FPRMExpr rm, BitVecExpr t, FPSort s, bool signed)
{
Contract.Ensures(Contract.Result<FPExpr>() != null);
if (signed)
return new FPExpr(this, Native.Z3_mk_fpa_to_fp_signed(this.nCtx, rm.NativeObject, t.NativeObject, s.NativeObject));
else
return new FPExpr(this, Native.Z3_mk_fpa_to_fp_unsigned(this.nCtx, rm.NativeObject, t.NativeObject, s.NativeObject));
}
/// <summary>
/// Conversion of a floating-point number to another FloatingPoint sort s.
/// </summary>
/// <remarks>
/// Produces a term that represents the conversion of a floating-point term t to a different
/// FloatingPoint sort s. If necessary, rounding according to rm is applied.
/// </remarks>
/// <param name="s">FloatingPoint sort</param>
/// <param name="rm">floating-point rounding mode term</param>
/// <param name="t">floating-point term</param>
public FPExpr MkFPToFP(FPSort s, FPRMExpr rm, FPExpr t)
{
Contract.Ensures(Contract.Result<FPExpr>() != null);
return new FPExpr(this, Native.Z3_mk_fpa_to_fp_float(this.nCtx, s.NativeObject, rm.NativeObject, t.NativeObject));
}
#endregion
#region Conversions from FloatingPoint terms
/// <summary>
/// Conversion of a floating-point term into a bit-vector.
/// </summary>
/// <remarks>
/// Produces a term that represents the conversion of the floating-poiunt term t into a
/// bit-vector term of size sz in 2's complement format (signed when signed==true). If necessary,
/// the result will be rounded according to rounding mode rm.
/// </remarks>
/// <param name="rm">RoundingMode term.</param>
/// <param name="t">FloatingPoint term</param>
/// <param name="sz">Size of the resulting bit-vector.</param>
/// <param name="signed">Indicates whether the result is a signed or unsigned bit-vector.</param>
public BitVecExpr MkFPToBV(FPRMExpr rm, FPExpr t, uint sz, bool signed)
{
Contract.Ensures(Contract.Result<BitVecExpr>() != null);
if (signed)
return new BitVecExpr(this, Native.Z3_mk_fpa_to_sbv(this.nCtx, rm.NativeObject, t.NativeObject, sz));
else
return new BitVecExpr(this, Native.Z3_mk_fpa_to_ubv(this.nCtx, rm.NativeObject, t.NativeObject, sz));
}
/// <summary>
/// Conversion of a floating-point term into a real-numbered term.
/// </summary>
/// <remarks>
/// Produces a term that represents the conversion of the floating-poiunt term t into a
/// real number. Note that this type of conversion will often result in non-linear
/// constraints over real terms.
/// </remarks>
/// <param name="t">FloatingPoint term</param>
public RealExpr MkFPToReal(FPExpr t)
{
Contract.Ensures(Contract.Result<RealExpr>() != null);
return new RealExpr(this, Native.Z3_mk_fpa_to_real(this.nCtx, t.NativeObject));
}
#endregion
#region Z3-specific extensions
/// <summary>
/// Conversion of a floating-point term into a bit-vector term in IEEE 754-2008 format.
/// </summary>
/// <remarks>
/// The size of the resulting bit-vector is automatically determined. Note that
/// IEEE 754-2008 allows multiple different representations of NaN. This conversion
/// knows only one NaN and it will always produce the same bit-vector represenatation of
/// that NaN.
/// </remarks>
/// <param name="t">FloatingPoint term.</param>
public BitVecExpr MkFPToIEEEBV(FPExpr t)
{
Contract.Ensures(Contract.Result<BitVecExpr>() != null);
return new BitVecExpr(this, Native.Z3_mk_fpa_to_ieee_bv(this.nCtx, t.NativeObject));
}
/// <summary>
/// Conversion of a real-sorted significand and an integer-sorted exponent into a term of FloatingPoint sort.
/// </summary>
/// <remarks>
/// Produces a term that represents the conversion of sig * 2^exp into a
/// floating-point term of sort s. If necessary, the result will be rounded
/// according to rounding mode rm.
/// </remarks>
/// <param name="rm">RoundingMode term.</param>
/// <param name="exp">Exponent term of Int sort.</param>
/// <param name="sig">Significand term of Real sort.</param>
/// <param name="s">FloatingPoint sort.</param>
public BitVecExpr MkFPToFP(FPRMExpr rm, IntExpr exp, RealExpr sig, FPSort s)
{
Contract.Ensures(Contract.Result<BitVecExpr>() != null);
return new BitVecExpr(this, Native.Z3_mk_fpa_to_fp_int_real(this.nCtx, rm.NativeObject, exp.NativeObject, sig.NativeObject, s.NativeObject));
}
#endregion
#endregion // Floating-point Arithmetic
#region Miscellaneous
/// <summary>
@ -3488,17 +4287,7 @@ namespace Microsoft.Z3
public ParamDescrs SimplifyParameterDescriptions
{
get { return new ParamDescrs(this, Native.Z3_simplify_get_param_descrs(nCtx)); }
}
/// <summary>
/// Enable/disable printing of warning messages to the console.
/// </summary>
/// <remarks>Note that this function is static and effects the behaviour of
/// all contexts globally.</remarks>
public static void ToggleWarningMessages(bool enabled)
{
Native.Z3_toggle_warning_messages((enabled) ? 1 : 0);
}
}
#endregion
#region Error Handling
@ -3597,36 +4386,95 @@ namespace Microsoft.Z3
}
readonly private AST.DecRefQueue m_AST_DRQ = new AST.DecRefQueue();
readonly private ASTMap.DecRefQueue m_ASTMap_DRQ = new ASTMap.DecRefQueue();
readonly private ASTVector.DecRefQueue m_ASTVector_DRQ = new ASTVector.DecRefQueue();
readonly private ApplyResult.DecRefQueue m_ApplyResult_DRQ = new ApplyResult.DecRefQueue();
readonly private FuncInterp.Entry.DecRefQueue m_FuncEntry_DRQ = new FuncInterp.Entry.DecRefQueue();
readonly private FuncInterp.DecRefQueue m_FuncInterp_DRQ = new FuncInterp.DecRefQueue();
readonly private Goal.DecRefQueue m_Goal_DRQ = new Goal.DecRefQueue();
readonly private Model.DecRefQueue m_Model_DRQ = new Model.DecRefQueue();
readonly private Params.DecRefQueue m_Params_DRQ = new Params.DecRefQueue();
readonly private ParamDescrs.DecRefQueue m_ParamDescrs_DRQ = new ParamDescrs.DecRefQueue();
readonly private Probe.DecRefQueue m_Probe_DRQ = new Probe.DecRefQueue();
readonly private Solver.DecRefQueue m_Solver_DRQ = new Solver.DecRefQueue();
readonly private Statistics.DecRefQueue m_Statistics_DRQ = new Statistics.DecRefQueue();
readonly private Tactic.DecRefQueue m_Tactic_DRQ = new Tactic.DecRefQueue();
readonly private Fixedpoint.DecRefQueue m_Fixedpoint_DRQ = new Fixedpoint.DecRefQueue();
readonly private ASTMap.DecRefQueue m_ASTMap_DRQ = new ASTMap.DecRefQueue(10);
readonly private ASTVector.DecRefQueue m_ASTVector_DRQ = new ASTVector.DecRefQueue(10);
readonly private ApplyResult.DecRefQueue m_ApplyResult_DRQ = new ApplyResult.DecRefQueue(10);
readonly private FuncInterp.Entry.DecRefQueue m_FuncEntry_DRQ = new FuncInterp.Entry.DecRefQueue(10);
readonly private FuncInterp.DecRefQueue m_FuncInterp_DRQ = new FuncInterp.DecRefQueue(10);
readonly private Goal.DecRefQueue m_Goal_DRQ = new Goal.DecRefQueue(10);
readonly private Model.DecRefQueue m_Model_DRQ = new Model.DecRefQueue(10);
readonly private Params.DecRefQueue m_Params_DRQ = new Params.DecRefQueue(10);
readonly private ParamDescrs.DecRefQueue m_ParamDescrs_DRQ = new ParamDescrs.DecRefQueue(10);
readonly private Probe.DecRefQueue m_Probe_DRQ = new Probe.DecRefQueue(10);
readonly private Solver.DecRefQueue m_Solver_DRQ = new Solver.DecRefQueue(10);
readonly private Statistics.DecRefQueue m_Statistics_DRQ = new Statistics.DecRefQueue(10);
readonly private Tactic.DecRefQueue m_Tactic_DRQ = new Tactic.DecRefQueue(10);
readonly private Fixedpoint.DecRefQueue m_Fixedpoint_DRQ = new Fixedpoint.DecRefQueue(10);
internal AST.DecRefQueue AST_DRQ { get { Contract.Ensures(Contract.Result<AST.DecRefQueue>() != null); return m_AST_DRQ; } }
internal ASTMap.DecRefQueue ASTMap_DRQ { get { Contract.Ensures(Contract.Result<ASTMap.DecRefQueue>() != null); return m_ASTMap_DRQ; } }
internal ASTVector.DecRefQueue ASTVector_DRQ { get { Contract.Ensures(Contract.Result<ASTVector.DecRefQueue>() != null); return m_ASTVector_DRQ; } }
internal ApplyResult.DecRefQueue ApplyResult_DRQ { get { Contract.Ensures(Contract.Result<ApplyResult.DecRefQueue>() != null); return m_ApplyResult_DRQ; } }
internal FuncInterp.Entry.DecRefQueue FuncEntry_DRQ { get { Contract.Ensures(Contract.Result<FuncInterp.Entry.DecRefQueue>() != null); return m_FuncEntry_DRQ; } }
internal FuncInterp.DecRefQueue FuncInterp_DRQ { get { Contract.Ensures(Contract.Result<FuncInterp.DecRefQueue>() != null); return m_FuncInterp_DRQ; } }
internal Goal.DecRefQueue Goal_DRQ { get { Contract.Ensures(Contract.Result<Goal.DecRefQueue>() != null); return m_Goal_DRQ; } }
internal Model.DecRefQueue Model_DRQ { get { Contract.Ensures(Contract.Result<Model.DecRefQueue>() != null); return m_Model_DRQ; } }
internal Params.DecRefQueue Params_DRQ { get { Contract.Ensures(Contract.Result<Params.DecRefQueue>() != null); return m_Params_DRQ; } }
internal ParamDescrs.DecRefQueue ParamDescrs_DRQ { get { Contract.Ensures(Contract.Result<ParamDescrs.DecRefQueue>() != null); return m_ParamDescrs_DRQ; } }
internal Probe.DecRefQueue Probe_DRQ { get { Contract.Ensures(Contract.Result<Probe.DecRefQueue>() != null); return m_Probe_DRQ; } }
internal Solver.DecRefQueue Solver_DRQ { get { Contract.Ensures(Contract.Result<Solver.DecRefQueue>() != null); return m_Solver_DRQ; } }
internal Statistics.DecRefQueue Statistics_DRQ { get { Contract.Ensures(Contract.Result<Statistics.DecRefQueue>() != null); return m_Statistics_DRQ; } }
internal Tactic.DecRefQueue Tactic_DRQ { get { Contract.Ensures(Contract.Result<Tactic.DecRefQueue>() != null); return m_Tactic_DRQ; } }
internal Fixedpoint.DecRefQueue Fixedpoint_DRQ { get { Contract.Ensures(Contract.Result<Fixedpoint.DecRefQueue>() != null); return m_Fixedpoint_DRQ; } }
/// <summary>
/// AST DRQ
/// </summary>
public IDecRefQueue AST_DRQ { get { Contract.Ensures(Contract.Result<AST.DecRefQueue>() != null); return m_AST_DRQ; } }
/// <summary>
/// ASTMap DRQ
/// </summary>
public IDecRefQueue ASTMap_DRQ { get { Contract.Ensures(Contract.Result<ASTMap.DecRefQueue>() != null); return m_ASTMap_DRQ; } }
/// <summary>
/// ASTVector DRQ
/// </summary>
public IDecRefQueue ASTVector_DRQ { get { Contract.Ensures(Contract.Result<ASTVector.DecRefQueue>() != null); return m_ASTVector_DRQ; } }
/// <summary>
/// ApplyResult DRQ
/// </summary>
public IDecRefQueue ApplyResult_DRQ { get { Contract.Ensures(Contract.Result<ApplyResult.DecRefQueue>() != null); return m_ApplyResult_DRQ; } }
/// <summary>
/// FuncEntry DRQ
/// </summary>
public IDecRefQueue FuncEntry_DRQ { get { Contract.Ensures(Contract.Result<FuncInterp.Entry.DecRefQueue>() != null); return m_FuncEntry_DRQ; } }
/// <summary>
/// FuncInterp DRQ
/// </summary>
public IDecRefQueue FuncInterp_DRQ { get { Contract.Ensures(Contract.Result<FuncInterp.DecRefQueue>() != null); return m_FuncInterp_DRQ; } }
/// <summary>
/// Goal DRQ
/// </summary>
public IDecRefQueue Goal_DRQ { get { Contract.Ensures(Contract.Result<Goal.DecRefQueue>() != null); return m_Goal_DRQ; } }
/// <summary>
/// Model DRQ
/// </summary>
public IDecRefQueue Model_DRQ { get { Contract.Ensures(Contract.Result<Model.DecRefQueue>() != null); return m_Model_DRQ; } }
/// <summary>
/// Params DRQ
/// </summary>
public IDecRefQueue Params_DRQ { get { Contract.Ensures(Contract.Result<Params.DecRefQueue>() != null); return m_Params_DRQ; } }
/// <summary>
/// ParamDescrs DRQ
/// </summary>
public IDecRefQueue ParamDescrs_DRQ { get { Contract.Ensures(Contract.Result<ParamDescrs.DecRefQueue>() != null); return m_ParamDescrs_DRQ; } }
/// <summary>
/// Probe DRQ
/// </summary>
public IDecRefQueue Probe_DRQ { get { Contract.Ensures(Contract.Result<Probe.DecRefQueue>() != null); return m_Probe_DRQ; } }
/// <summary>
/// Solver DRQ
/// </summary>
public IDecRefQueue Solver_DRQ { get { Contract.Ensures(Contract.Result<Solver.DecRefQueue>() != null); return m_Solver_DRQ; } }
/// <summary>
/// Statistics DRQ
/// </summary>
public IDecRefQueue Statistics_DRQ { get { Contract.Ensures(Contract.Result<Statistics.DecRefQueue>() != null); return m_Statistics_DRQ; } }
/// <summary>
/// Tactic DRQ
/// </summary>
public IDecRefQueue Tactic_DRQ { get { Contract.Ensures(Contract.Result<Tactic.DecRefQueue>() != null); return m_Tactic_DRQ; } }
/// <summary>
/// FixedPoint DRQ
/// </summary>
public IDecRefQueue Fixedpoint_DRQ { get { Contract.Ensures(Contract.Result<Fixedpoint.DecRefQueue>() != null); return m_Fixedpoint_DRQ; } }
internal long refCount = 0;

View file

@ -32,11 +32,6 @@ namespace Microsoft.Z3
{
#region Internal
/// <summary> Constructor for DatatypeExpr </summary>
internal protected DatatypeExpr(Context ctx)
: base(ctx)
{
Contract.Requires(ctx != null);
}
internal DatatypeExpr(Context ctx, IntPtr obj)
: base(ctx, obj)
{

View file

@ -44,6 +44,16 @@ namespace Microsoft.Z3
}
}
/// <summary>
/// Retrieves the inx'th constant declaration in the enumeration.
/// </summary>
/// <param name="inx"></param>
/// <returns></returns>
public FuncDecl ConstDecl(uint inx)
{
return new FuncDecl(Context, Native.Z3_get_datatype_sort_constructor(Context.nCtx, NativeObject, inx));
}
/// <summary>
/// The constants in the enumeration.
/// </summary>
@ -61,7 +71,17 @@ namespace Microsoft.Z3
}
/// <summary>
/// The test predicates for the constants in the enumeration.
/// Retrieves the inx'th constant in the enumeration.
/// </summary>
/// <param name="inx"></param>
/// <returns></returns>
public Expr Const(uint inx)
{
return Context.MkApp(ConstDecl(inx));
}
/// <summary>
/// The test predicates (recognizers) for the constants in the enumeration.
/// </summary>
public FuncDecl[] TesterDecls
{
@ -76,9 +96,19 @@ namespace Microsoft.Z3
}
}
/// <summary>
/// Retrieves the inx'th tester/recognizer declaration in the enumeration.
/// </summary>
/// <param name="inx"></param>
/// <returns></returns>
public FuncDecl TesterDecl(uint inx)
{
return new FuncDecl(Context, Native.Z3_get_datatype_sort_recognizer(Context.nCtx, NativeObject, inx));
}
#region Internal
internal EnumSort(Context ctx, Symbol name, Symbol[] enumNames)
: base(ctx)
: base(ctx, IntPtr.Zero)
{
Contract.Requires(ctx != null);
Contract.Requires(name != null);

View file

@ -1311,7 +1311,7 @@ namespace Microsoft.Z3
#region Relational Terms
/// <summary>
/// Indicates whether the term is of an array sort.
/// Indicates whether the term is of relation sort.
/// </summary>
public bool IsRelation
{
@ -1448,6 +1448,281 @@ namespace Microsoft.Z3
/// Indicates whether the term is a less than predicate over a finite domain.
/// </summary>
public bool IsFiniteDomainLT { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FD_LT; } }
#endregion
#region Floating-point terms
/// <summary>
/// Indicates whether the terms is of floating-point sort.
/// </summary>
public bool IsFP
{
get { return Native.Z3_get_sort_kind(Context.nCtx, Native.Z3_get_sort(Context.nCtx, NativeObject)) == (uint)Z3_sort_kind.Z3_FLOATING_POINT_SORT; }
}
/// <summary>
/// Indicates whether the terms is of floating-point rounding mode sort.
/// </summary>
public bool IsFPRM
{
get { return Native.Z3_get_sort_kind(Context.nCtx, Native.Z3_get_sort(Context.nCtx, NativeObject)) == (uint)Z3_sort_kind.Z3_ROUNDING_MODE_SORT; }
}
/// <summary>
/// Indicates whether the term is a floating-point numeral
/// </summary>
public bool IsFPNumeral { get { return IsFP && IsNumeral; } }
/// <summary>
/// Indicates whether the term is a floating-point rounding mode numeral
/// </summary>
public bool IsFPRMNumeral { get { return IsFPRM && IsNumeral; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundNearestTiesToEven
/// </summary>
public bool IsFPRMRoundNearestTiesToEven{ get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundNearestTiesToAway
/// </summary>
public bool IsFPRMRoundNearestTiesToAway{ get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundTowardNegative
/// </summary>
public bool IsFPRMRoundTowardNegative{ get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_NEGATIVE; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundTowardPositive
/// </summary>
public bool IsFPRMRoundTowardPositive{ get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_POSITIVE; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundTowardZero
/// </summary>
public bool IsFPRMRoundTowardZero{ get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_ZERO; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundNearestTiesToEven
/// </summary>
public bool IsFPRMExprRNE{ get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundNearestTiesToAway
/// </summary>
public bool IsFPRMExprRNA { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundTowardNegative
/// </summary>
public bool IsFPRMExprRTN { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_NEGATIVE; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundTowardPositive
/// </summary>
public bool IsFPRMExprRTP { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_POSITIVE; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundTowardZero
/// </summary>
public bool IsFPRMExprRTZ { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_ZERO; } }
/// <summary>
/// Indicates whether the term is a floating-point rounding mode numeral
/// </summary>
public bool IsFPRMExpr {
get {
return IsApp &&
(FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY||
FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN ||
FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_POSITIVE ||
FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_NEGATIVE ||
FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_ZERO);
}
}
/// <summary>
/// Indicates whether the term is a floating-point +oo
/// </summary>
public bool IsFPPlusInfinity{ get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_PLUS_INF; } }
/// <summary>
/// Indicates whether the term is a floating-point -oo
/// </summary>
public bool IsFPMinusInfinity{ get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_MINUS_INF; } }
/// <summary>
/// Indicates whether the term is a floating-point NaN
/// </summary>
public bool IsFPNaN { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_NAN; } }
/// <summary>
/// Indicates whether the term is a floating-point +zero
/// </summary>
public bool IsFPPlusZero { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_PLUS_ZERO; } }
/// <summary>
/// Indicates whether the term is a floating-point -zero
/// </summary>
public bool IsFPMinusZero { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_MINUS_ZERO; } }
/// <summary>
/// Indicates whether the term is a floating-point addition term
/// </summary>
public bool IsFPAdd { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_ADD; } }
/// <summary>
/// Indicates whether the term is a floating-point subtraction term
/// </summary>
public bool IsFPSub { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_SUB; } }
/// <summary>
/// Indicates whether the term is a floating-point negation term
/// </summary>
public bool IsFPNeg { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_NEG; } }
/// <summary>
/// Indicates whether the term is a floating-point multiplication term
/// </summary>
public bool IsFPMul { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_MUL; } }
/// <summary>
/// Indicates whether the term is a floating-point divison term
/// </summary>
public bool IsFPDiv { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_DIV; } }
/// <summary>
/// Indicates whether the term is a floating-point remainder term
/// </summary>
public bool IsFPRem { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_REM; } }
/// <summary>
/// Indicates whether the term is a floating-point term absolute value term
/// </summary>
public bool IsFPAbs { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_ABS; } }
/// <summary>
/// Indicates whether the term is a floating-point minimum term
/// </summary>
public bool IsFPMin { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_MIN; } }
/// <summary>
/// Indicates whether the term is a floating-point maximum term
/// </summary>
public bool IsFPMax { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_MAX; } }
/// <summary>
/// Indicates whether the term is a floating-point fused multiply-add term
/// </summary>
public bool IsFPFMA { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_FMA; } }
/// <summary>
/// Indicates whether the term is a floating-point square root term
/// </summary>
public bool IsFPSqrt { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_SQRT; } }
/// <summary>
/// Indicates whether the term is a floating-point roundToIntegral term
/// </summary>
public bool IsFPRoundToIntegral { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_ROUND_TO_INTEGRAL; } }
/// <summary>
/// Indicates whether the term is a floating-point equality term
/// </summary>
public bool IsFPEq { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_EQ; } }
/// <summary>
/// Indicates whether the term is a floating-point less-than term
/// </summary>
public bool IsFPLt { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_LT; } }
/// <summary>
/// Indicates whether the term is a floating-point greater-than term
/// </summary>
public bool IsFPGt { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_GT; } }
/// <summary>
/// Indicates whether the term is a floating-point less-than or equal term
/// </summary>
public bool IsFPLe { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_LE; } }
/// <summary>
/// Indicates whether the term is a floating-point greater-than or erqual term
/// </summary>
public bool IsFPGe { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_GE; } }
/// <summary>
/// Indicates whether the term is a floating-point isNaN predicate term
/// </summary>
public bool IsFPisNaN { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_IS_NAN; } }
/// <summary>
/// Indicates whether the term is a floating-point isInf predicate term
/// </summary>
public bool IsFPisInf { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_IS_INF; } }
/// <summary>
/// Indicates whether the term is a floating-point isZero predicate term
/// </summary>
public bool IsFPisZero { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_IS_ZERO; } }
/// <summary>
/// Indicates whether the term is a floating-point isNormal term
/// </summary>
public bool IsFPisNormal { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_IS_NORMAL; } }
/// <summary>
/// Indicates whether the term is a floating-point isSubnormal predicate term
/// </summary>
public bool IsFPisSubnormal { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_IS_SUBNORMAL; } }
/// <summary>
/// Indicates whether the term is a floating-point isNegative predicate term
/// </summary>
public bool IsFPisNegative { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_IS_NEGATIVE; } }
/// <summary>
/// Indicates whether the term is a floating-point isPositive predicate term
/// </summary>
public bool IsFPisPositive { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_IS_POSITIVE; } }
/// <summary>
/// Indicates whether the term is a floating-point constructor term
/// </summary>
public bool IsFPFP { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_FP; } }
/// <summary>
/// Indicates whether the term is a floating-point conversion term
/// </summary>
public bool IsFPToFp { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_TO_FP; } }
/// <summary>
/// Indicates whether the term is a floating-point conversion from unsigned bit-vector term
/// </summary>
public bool IsFPToFpUnsigned { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_TO_FP_UNSIGNED; } }
/// <summary>
/// Indicates whether the term is a floating-point conversion to unsigned bit-vector term
/// </summary>
public bool IsFPToUBV { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_TO_UBV; } }
/// <summary>
/// Indicates whether the term is a floating-point conversion to signed bit-vector term
/// </summary>
public bool IsFPToSBV { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_TO_SBV; } }
/// <summary>
/// Indicates whether the term is a floating-point conversion to real term
/// </summary>
public bool IsFPToReal { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_TO_REAL; } }
/// <summary>
/// Indicates whether the term is a floating-point conversion to IEEE-754 bit-vector term
/// </summary>
public bool IsFPToIEEEBV { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_TO_IEEE_BV; } }
#endregion
#endregion
@ -1489,10 +1764,6 @@ namespace Microsoft.Z3
/// <summary>
/// Constructor for Expr
/// </summary>
internal protected Expr(Context ctx) : base(ctx) { Contract.Requires(ctx != null); }
/// <summary>
/// Constructor for Expr
/// </summary>
internal protected Expr(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
#if DEBUG
@ -1541,7 +1812,9 @@ namespace Microsoft.Z3
{
case Z3_sort_kind.Z3_INT_SORT: return new IntNum(ctx, obj);
case Z3_sort_kind.Z3_REAL_SORT: return new RatNum(ctx, obj);
case Z3_sort_kind.Z3_BV_SORT: return new BitVecNum(ctx, obj);
case Z3_sort_kind.Z3_BV_SORT: return new BitVecNum(ctx, obj);
case Z3_sort_kind.Z3_FLOATING_POINT_SORT: return new FPNum(ctx, obj);
case Z3_sort_kind.Z3_ROUNDING_MODE_SORT: return new FPRMNum(ctx, obj);
}
}
@ -1552,7 +1825,9 @@ namespace Microsoft.Z3
case Z3_sort_kind.Z3_REAL_SORT: return new RealExpr(ctx, obj);
case Z3_sort_kind.Z3_BV_SORT: return new BitVecExpr(ctx, obj);
case Z3_sort_kind.Z3_ARRAY_SORT: return new ArrayExpr(ctx, obj);
case Z3_sort_kind.Z3_DATATYPE_SORT: return new DatatypeExpr(ctx, obj);
case Z3_sort_kind.Z3_DATATYPE_SORT: return new DatatypeExpr(ctx, obj);
case Z3_sort_kind.Z3_FLOATING_POINT_SORT: return new FPExpr(ctx, obj);
case Z3_sort_kind.Z3_ROUNDING_MODE_SORT: return new FPRMExpr(ctx, obj);
}
return new Expr(ctx, obj);

52
src/api/dotnet/FPExpr.cs Normal file
View file

@ -0,0 +1,52 @@
/*++
Copyright (c) 2013 Microsoft Corporation
Module Name:
FPExpr.cs
Abstract:
Z3 Managed API: Floating Point Expressions
Author:
Christoph Wintersteiger (cwinter) 2013-06-10
Notes:
--*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// FloatingPoint Expressions
/// </summary>
public class FPExpr : Expr
{
/// <summary>
/// The number of exponent bits.
/// </summary>
public uint EBits { get { return ((FPSort)Sort).EBits; } }
/// <summary>
/// The number of significand bits.
/// </summary>
public uint SBits { get { return ((FPSort)Sort).EBits; } }
#region Internal
/// <summary> Constructor for FPExpr </summary>
internal FPExpr(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
}
#endregion
}
}

103
src/api/dotnet/FPNum.cs Normal file
View file

@ -0,0 +1,103 @@
/*++
Copyright (c) 2013 Microsoft Corporation
Module Name:
FPNum.cs
Abstract:
Z3 Managed API: Floating Point Numerals
Author:
Christoph Wintersteiger (cwinter) 2013-06-10
Notes:
--*/
using System;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// FloatiungPoint Numerals
/// </summary>
[ContractVerification(true)]
public class FPNum : FPExpr
{
/// <summary>
/// Retrieves the sign of a floating-point literal
/// </summary>
/// <remarks>
/// Remarks: returns true if the numeral is negative
/// </remarks>
public bool Sign
{
get
{
int res = 0;
if (Native.Z3_fpa_get_numeral_sign(Context.nCtx, NativeObject, ref res) == 0)
throw new Z3Exception("Sign is not a Boolean value");
return res != 0;
}
}
/// <summary>
/// The significand value of a floating-point numeral as a string
/// </summary>
/// <remarks>
/// The significand s is always 0 &lt; s &lt; 2.0; the resulting string is long
/// enough to represent the real significand precisely.
/// </remarks>
public string Significand
{
get
{
return Native.Z3_fpa_get_numeral_significand_string(Context.nCtx, NativeObject);
}
}
/// <summary>
/// Return the exponent value of a floating-point numeral as a string
/// </summary>
public string Exponent
{
get
{
return Native.Z3_fpa_get_numeral_exponent_string(Context.nCtx, NativeObject);
}
}
/// <summary>
/// Return the exponent value of a floating-point numeral as a signed 64-bit integer
/// </summary>
public Int64 ExponentInt64
{
get
{
Int64 result = 0;
if (Native.Z3_fpa_get_numeral_exponent_int64(Context.nCtx, NativeObject, ref result) == 0)
throw new Z3Exception("Exponent is not a 64 bit integer");
return result;
}
}
#region Internal
internal FPNum(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
}
#endregion
/// <summary>
/// Returns a string representation of the numeral.
/// </summary>
public override string ToString()
{
return Native.Z3_get_numeral_string(Context.nCtx, NativeObject);
}
}
}

View file

@ -0,0 +1,42 @@
/*++
Copyright (c) 2013 Microsoft Corporation
Module Name:
FPRMExpr.cs
Abstract:
Z3 Managed API: Floating Point Expressions over Rounding Modes
Author:
Christoph Wintersteiger (cwinter) 2013-06-10
Notes:
--*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// FloatingPoint RoundingMode Expressions
/// </summary>
public class FPRMExpr : Expr
{
#region Internal
/// <summary> Constructor for FPRMExpr </summary>
internal FPRMExpr(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
}
#endregion
}
}

100
src/api/dotnet/FPRMNum.cs Normal file
View file

@ -0,0 +1,100 @@
/*++
Copyright (c) 2013 Microsoft Corporation
Module Name:
FPRMExpr.cs
Abstract:
Z3 Managed API: Floating Point Rounding Mode Numerals
Author:
Christoph Wintersteiger (cwinter) 2013-06-10
Notes:
--*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// Floating-point rounding mode numerals
/// </summary>
public class FPRMNum : FPRMExpr
{
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundNearestTiesToEven
/// </summary>
public bool isRoundNearestTiesToEven { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundNearestTiesToEven
/// </summary>
public bool isRNE { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundNearestTiesToAway
/// </summary>
public bool isRoundNearestTiesToAway { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundNearestTiesToAway
/// </summary>
public bool isRNA { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundTowardPositive
/// </summary>
public bool isRoundTowardPositive { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_POSITIVE; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundTowardPositive
/// </summary>
public bool isRTP { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_POSITIVE; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundTowardNegative
/// </summary>
public bool isRoundTowardNegative { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_NEGATIVE; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundTowardNegative
/// </summary>
public bool isRTN { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_NEGATIVE; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundTowardZero
/// </summary>
public bool isRoundTowardZero { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_ZERO; } }
/// <summary>
/// Indicates whether the term is the floating-point rounding numeral roundTowardZero
/// </summary>
public bool isRTZ { get { return IsApp && FuncDecl.DeclKind == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_ZERO; } }
/// <summary>
/// Returns a string representation of the numeral.
/// </summary>
public override string ToString()
{
return Native.Z3_get_numeral_string(Context.nCtx, NativeObject);
}
#region Internal
/// <summary> Constructor for FPRMNum </summary>
internal FPRMNum(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
}
#endregion
}
}

View file

@ -0,0 +1,43 @@
/*++
Copyright (c) 2013 Microsoft Corporation
Module Name:
FPRMSort.cs
Abstract:
Z3 Managed API: Rounding Mode Sort
Author:
Christoph Wintersteiger (cwinter) 2013-06-10
Notes:
--*/
using System;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// The FloatingPoint RoundingMode sort
/// </summary>
public class FPRMSort : Sort
{
#region Internal
internal FPRMSort(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(ctx != null);
}
internal FPRMSort(Context ctx)
: base(ctx, Native.Z3_mk_fpa_rounding_mode_sort(ctx.nCtx))
{
Contract.Requires(ctx != null);
}
#endregion
}
}

52
src/api/dotnet/FPSort.cs Normal file
View file

@ -0,0 +1,52 @@
/*++
Copyright (c) 2013 Microsoft Corporation
Module Name:
FPSort.cs
Abstract:
Z3 Managed API: Floating Point Sorts
Author:
Christoph Wintersteiger (cwinter) 2013-06-10
Notes:
--*/
using System;
using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// FloatingPoint sort
/// </summary>
public class FPSort : Sort
{
/// <summary>
/// The number of exponent bits.
/// </summary>
public uint EBits { get { return Native.Z3_fpa_get_ebits(Context.nCtx, NativeObject); } }
/// <summary>
/// The number of significand bits.
/// </summary>
public uint SBits { get { return Native.Z3_fpa_get_sbits(Context.nCtx, NativeObject); } }
#region Internal
internal FPSort(Context ctx, IntPtr obj)
: base(ctx, obj)
{
Contract.Requires(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);
}
#endregion
}
}

View file

@ -335,12 +335,14 @@ namespace Microsoft.Z3
internal class DecRefQueue : IDecRefQueue
{
public override void IncRef(Context ctx, IntPtr obj)
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_fixedpoint_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_fixedpoint_dec_ref(ctx.nCtx, obj);
}

View file

@ -91,12 +91,14 @@ namespace Microsoft.Z3
internal class DecRefQueue : IDecRefQueue
{
public override void IncRef(Context ctx, IntPtr obj)
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_func_entry_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_func_entry_dec_ref(ctx.nCtx, obj);
}
@ -197,12 +199,14 @@ namespace Microsoft.Z3
internal class DecRefQueue : IDecRefQueue
{
public override void IncRef(Context ctx, IntPtr obj)
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_func_interp_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_func_interp_dec_ref(ctx.nCtx, obj);
}

View file

@ -82,6 +82,40 @@ namespace Microsoft.Z3
public static void ResetParameters()
{
Native.Z3_global_param_reset_all();
}
}
/// <summary>
/// Enable/disable printing of warning messages to the console.
/// </summary>
/// <remarks>Note that this function is static and effects the behaviour of
/// all contexts globally.</remarks>
public static void ToggleWarningMessages(bool enabled)
{
Native.Z3_toggle_warning_messages((enabled) ? 1 : 0);
}
/// <summary>
/// Enable tracing messages tagged as `tag' when Z3 is compiled in debug mode.
/// </summary>
/// <remarks>
/// It is a NOOP otherwise.
/// </remarks>
/// <param name="tag">trace tag</param>
public static void EnableTrace(string tag)
{
Native.Z3_enable_trace(tag);
}
/// <summary>
/// Disable tracing messages tagged as `tag' when Z3 is compiled in debug mode.
/// </summary>
/// <remarks>
/// It is a NOOP otherwise.
/// </remarks>
/// <param name="tag">trace tag</param>
public static void DisableTrace(string tag)
{
Native.Z3_disable_trace(tag);
}
}
}

View file

@ -219,12 +219,14 @@ namespace Microsoft.Z3
internal class DecRefQueue : IDecRefQueue
{
public override void IncRef(Context ctx, IntPtr obj)
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_goal_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_goal_dec_ref(ctx.nCtx, obj);
}

View file

@ -25,8 +25,11 @@ using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// DecRefQueue interface
/// </summary>
[ContractClass(typeof(DecRefQueueContracts))]
internal abstract class IDecRefQueue
public abstract class IDecRefQueue
{
#region Object invariant
@ -38,14 +41,25 @@ namespace Microsoft.Z3
#endregion
readonly internal protected Object m_lock = new Object();
readonly internal protected List<IntPtr> m_queue = new List<IntPtr>();
internal const uint m_move_limit = 1024;
readonly private Object m_lock = new Object();
readonly private List<IntPtr> m_queue = new List<IntPtr>();
private uint m_move_limit;
public abstract void IncRef(Context ctx, IntPtr obj);
public abstract void DecRef(Context ctx, IntPtr obj);
internal IDecRefQueue(uint move_limit = 1024)
{
m_move_limit = move_limit;
}
public void IncAndClear(Context ctx, IntPtr o)
/// <summary>
/// Sets the limit on numbers of objects that are kept back at GC collection.
/// </summary>
/// <param name="l"></param>
public void SetLimit(uint l) { m_move_limit = l; }
internal abstract void IncRef(Context ctx, IntPtr obj);
internal abstract void DecRef(Context ctx, IntPtr obj);
internal void IncAndClear(Context ctx, IntPtr o)
{
Contract.Requires(ctx != null);
@ -53,7 +67,7 @@ namespace Microsoft.Z3
if (m_queue.Count >= m_move_limit) Clear(ctx);
}
public void Add(IntPtr o)
internal void Add(IntPtr o)
{
if (o == IntPtr.Zero) return;
@ -63,7 +77,7 @@ namespace Microsoft.Z3
}
}
public void Clear(Context ctx)
internal void Clear(Context ctx)
{
Contract.Requires(ctx != null);
@ -79,12 +93,12 @@ namespace Microsoft.Z3
[ContractClassFor(typeof(IDecRefQueue))]
abstract class DecRefQueueContracts : IDecRefQueue
{
public override void IncRef(Context ctx, IntPtr obj)
internal override void IncRef(Context ctx, IntPtr obj)
{
Contract.Requires(ctx != null);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Contract.Requires(ctx != null);
}

View file

@ -1,5 +1,5 @@
/*++
Copyright (<c>) 2012 Microsoft Corporation
Copyright (c) 2012 Microsoft Corporation
Module Name:
@ -32,11 +32,6 @@ namespace Microsoft.Z3
{
#region Internal
/// <summary> Constructor for IntExpr </summary>
internal protected IntExpr(Context ctx)
: base(ctx)
{
Contract.Requires(ctx != null);
}
internal IntExpr(Context ctx, IntPtr obj)
: base(ctx, obj)
{

View file

@ -13,7 +13,7 @@ namespace Microsoft.Z3
/// <remarks>For more information on interpolation please refer
/// too the C/C++ API, which is well documented.</remarks>
[ContractVerification(true)]
class InterpolationContext : Context
public class InterpolationContext : Context
{
/// <summary>
@ -47,7 +47,7 @@ namespace Microsoft.Z3
/// <remarks>For more information on interpolation please refer
/// too the function Z3_get_interpolant in the C/C++ API, which is
/// well documented.</remarks>
Expr[] GetInterpolant(Expr pf, Expr pat, Params p)
public Expr[] GetInterpolant(Expr pf, Expr pat, Params p)
{
Contract.Requires(pf != null);
Contract.Requires(pat != null);
@ -72,7 +72,7 @@ namespace Microsoft.Z3
/// <remarks>For more information on interpolation please refer
/// too the function Z3_compute_interpolant in the C/C++ API, which is
/// well documented.</remarks>
Z3_lbool ComputeInterpolant(Expr pat, Params p, out ASTVector interp, out Model model)
public Z3_lbool ComputeInterpolant(Expr pat, Params p, out ASTVector interp, out Model model)
{
Contract.Requires(pat != null);
Contract.Requires(p != null);

View file

@ -113,9 +113,9 @@ namespace Microsoft.Z3
}
}
#region Internal
#region Internal
internal ListSort(Context ctx, Symbol name, Sort elemSort)
: base(ctx)
: base(ctx, IntPtr.Zero)
{
Contract.Requires(ctx != null);
Contract.Requires(name != null);

View file

@ -19,12 +19,12 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\..\..\..\cwinter\bugs\z3bugs\Debug\</OutputPath>
<OutputPath>..\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>C:\cwinter\bugs\z3bugs\Debug\Microsoft.Z3.XML</DocumentationFile>
<DocumentationFile>..\Debug\Microsoft.Z3.XML</DocumentationFile>
<CodeContractsEnableRuntimeChecking>False</CodeContractsEnableRuntimeChecking>
<CodeContractsRuntimeOnlyPublicSurface>False</CodeContractsRuntimeOnlyPublicSurface>
<CodeContractsRuntimeThrowOnFailure>True</CodeContractsRuntimeThrowOnFailure>
@ -254,7 +254,7 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>..\..\..\..\..\cwinter\bugs\z3bugs\Debug\</OutputPath>
<OutputPath>..\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugType>full</DebugType>
@ -266,7 +266,7 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
<DocumentationFile>C:\cwinter\bugs\z3bugs\Debug\Microsoft.Z3.XML</DocumentationFile>
<DocumentationFile>..\x86\Debug\Microsoft.Z3.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
@ -342,6 +342,12 @@
<Compile Include="ConstructorList.cs" />
<Compile Include="DatatypeExpr.cs" />
<Compile Include="DatatypeSort.cs" />
<Compile Include="FPExpr.cs" />
<Compile Include="FPNum.cs" />
<Compile Include="FPRMExpr.cs" />
<Compile Include="FPRMNum.cs" />
<Compile Include="FPRMSort.cs" />
<Compile Include="FPSort.cs" />
<Compile Include="Global.cs" />
<Compile Include="IDecRefQueue.cs" />
<Compile Include="Enumerations.cs" />

View file

@ -291,12 +291,14 @@ namespace Microsoft.Z3
internal class DecRefQueue : IDecRefQueue
{
public override void IncRef(Context ctx, IntPtr obj)
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_model_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_model_dec_ref(ctx.nCtx, obj);
}

View file

@ -87,12 +87,14 @@ namespace Microsoft.Z3
internal class DecRefQueue : IDecRefQueue
{
public override void IncRef(Context ctx, IntPtr obj)
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_param_descrs_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_param_descrs_dec_ref(ctx.nCtx, obj);
}

View file

@ -23,7 +23,7 @@ using System.Diagnostics.Contracts;
namespace Microsoft.Z3
{
/// <summary>
/// A ParameterSet represents a configuration in the form of Symbol/value pairs.
/// A Params objects represents a configuration in the form of Symbol/value pairs.
/// </summary>
[ContractVerification(true)]
public class Params : Z3Object
@ -140,12 +140,14 @@ namespace Microsoft.Z3
internal class DecRefQueue : IDecRefQueue
{
public override void IncRef(Context ctx, IntPtr obj)
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_params_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_params_dec_ref(ctx.nCtx, obj);
}

View file

@ -73,12 +73,14 @@ namespace Microsoft.Z3
internal class DecRefQueue : IDecRefQueue
{
public override void IncRef(Context ctx, IntPtr obj)
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_probe_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_probe_dec_ref(ctx.nCtx, obj);
}

View file

@ -160,7 +160,7 @@ 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)
: base(ctx, IntPtr.Zero)
{
Contract.Requires(ctx != null);
Contract.Requires(sorts != null);
@ -203,7 +203,7 @@ 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)
: base(ctx, IntPtr.Zero)
{
Contract.Requires(ctx != null);
Contract.Requires(body != null);

View file

@ -0,0 +1,9 @@
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 condidional compilation symbols
- Remove the reference to System.Numerics
- Install the NuGet Package "Microsoft Code Contracts for Net3.5"

View file

@ -32,11 +32,6 @@ namespace Microsoft.Z3
{
#region Internal
/// <summary> Constructor for RealExpr </summary>
internal protected RealExpr(Context ctx)
: base(ctx)
{
Contract.Requires(ctx != null);
}
internal RealExpr(Context ctx, IntPtr obj)
: base(ctx, obj)
{

View file

@ -328,12 +328,14 @@ namespace Microsoft.Z3
internal class DecRefQueue : IDecRefQueue
{
public override void IncRef(Context ctx, IntPtr obj)
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_solver_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_solver_dec_ref(ctx.nCtx, obj);
}

View file

@ -116,8 +116,7 @@ namespace Microsoft.Z3
#region Internal
/// <summary>
/// Sort constructor
/// </summary>
internal protected Sort(Context ctx) : base(ctx) { Contract.Requires(ctx != null); }
/// </summary>
internal Sort(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
#if DEBUG
@ -146,6 +145,8 @@ namespace Microsoft.Z3
case Z3_sort_kind.Z3_UNINTERPRETED_SORT: return new UninterpretedSort(ctx, obj);
case Z3_sort_kind.Z3_FINITE_DOMAIN_SORT: return new FiniteDomainSort(ctx, obj);
case Z3_sort_kind.Z3_RELATION_SORT: return new RelationSort(ctx, obj);
case Z3_sort_kind.Z3_FLOATING_POINT_SORT: return new FPSort(ctx, obj);
case Z3_sort_kind.Z3_ROUNDING_MODE_SORT: return new FPRMSort(ctx, obj);
default:
throw new Z3Exception("Unknown sort kind");
}

View file

@ -189,12 +189,14 @@ namespace Microsoft.Z3
internal class DecRefQueue : IDecRefQueue
{
public override void IncRef(Context ctx, IntPtr obj)
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_stats_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_stats_dec_ref(ctx.nCtx, obj);
}

View file

@ -112,14 +112,19 @@ namespace Microsoft.Z3
Contract.Requires(ctx != null);
}
/// <summary>
/// DecRefQueue
/// </summary>
internal class DecRefQueue : IDecRefQueue
{
public override void IncRef(Context ctx, IntPtr obj)
public DecRefQueue() : base() { }
public DecRefQueue(uint move_limit) : base(move_limit) { }
internal override void IncRef(Context ctx, IntPtr obj)
{
Native.Z3_tactic_inc_ref(ctx.nCtx, obj);
}
public override void DecRef(Context ctx, IntPtr obj)
internal override void DecRef(Context ctx, IntPtr obj)
{
Native.Z3_tactic_dec_ref(ctx.nCtx, obj);
}

View file

@ -68,7 +68,7 @@ namespace Microsoft.Z3
#region Internal
internal TupleSort(Context ctx, Symbol name, uint numFields, Symbol[] fieldNames, Sort[] fieldSorts)
: base(ctx)
: base(ctx, IntPtr.Zero)
{
Contract.Requires(ctx != null);
Contract.Requires(name != null);

View file

@ -28,7 +28,8 @@ public class AST extends Z3Object
/**
* Object comparison.
* <param name="o">another AST</param>
*
* @param o another AST
**/
public boolean equals(Object o)
{
@ -46,12 +47,14 @@ public class AST extends Z3Object
}
/**
* Object Comparison. <param name="other">Another AST</param>
* Object Comparison.
* @param other Another AST
*
* @return Negative if the object should be sorted before <paramref
* name="other"/>, positive if after else zero.
* @return Negative if the object should be sorted before {@code other},
* positive if after else zero.
* @throws Z3Exception on error
**/
public int compareTo(Object other) throws Z3Exception
public int compareTo(Object other)
{
if (other == null)
return 1;
@ -90,19 +93,21 @@ public class AST extends Z3Object
/**
* A unique identifier for the AST (unique among all ASTs).
* @throws Z3Exception on error
**/
public int getId() throws Z3Exception
public int getId()
{
return Native.getAstId(getContext().nCtx(), getNativeObject());
}
/**
* Translates (copies) the AST to the Context <paramref name="ctx"/>. <param
* name="ctx">A context</param>
* Translates (copies) the AST to the Context {@code ctx}.
* @param ctx A context
*
* @return A copy of the AST which is associated with <paramref name="ctx"/>
* @return A copy of the AST which is associated with {@code ctx}
* @throws Z3Exception on error
**/
public AST translate(Context ctx) throws Z3Exception
public AST translate(Context ctx)
{
if (getContext() == ctx)
@ -114,8 +119,9 @@ public class AST extends Z3Object
/**
* The kind of the AST.
* @throws Z3Exception on error
**/
public Z3_ast_kind getASTKind() throws Z3Exception
public Z3_ast_kind getASTKind()
{
return Z3_ast_kind.fromInt(Native.getAstKind(getContext().nCtx(),
getNativeObject()));
@ -123,8 +129,10 @@ public class AST extends Z3Object
/**
* Indicates whether the AST is an Expr
* @throws Z3Exception on error
* @throws Z3Exception on error
**/
public boolean isExpr() throws Z3Exception
public boolean isExpr()
{
switch (getASTKind())
{
@ -140,24 +148,30 @@ public class AST extends Z3Object
/**
* Indicates whether the AST is an application
* @return a boolean
* @throws Z3Exception on error
**/
public boolean isApp() throws Z3Exception
public boolean isApp()
{
return this.getASTKind() == Z3_ast_kind.Z3_APP_AST;
}
/**
* Indicates whether the AST is a BoundVariable
* Indicates whether the AST is a BoundVariable.
* @return a boolean
* @throws Z3Exception on error
**/
public boolean isVar() throws Z3Exception
public boolean isVar()
{
return this.getASTKind() == Z3_ast_kind.Z3_VAR_AST;
}
/**
* Indicates whether the AST is a Quantifier
* @return a boolean
* @throws Z3Exception on error
**/
public boolean isQuantifier() throws Z3Exception
public boolean isQuantifier()
{
return this.getASTKind() == Z3_ast_kind.Z3_QUANTIFIER_AST;
}
@ -165,7 +179,7 @@ public class AST extends Z3Object
/**
* Indicates whether the AST is a Sort
**/
public boolean isSort() throws Z3Exception
public boolean isSort()
{
return this.getASTKind() == Z3_ast_kind.Z3_SORT_AST;
}
@ -173,7 +187,7 @@ public class AST extends Z3Object
/**
* Indicates whether the AST is a FunctionDeclaration
**/
public boolean isFuncDecl() throws Z3Exception
public boolean isFuncDecl()
{
return this.getASTKind() == Z3_ast_kind.Z3_FUNC_DECL_AST;
}
@ -195,7 +209,7 @@ public class AST extends Z3Object
/**
* A string representation of the AST in s-expression notation.
**/
public String getSExpr() throws Z3Exception
public String getSExpr()
{
return Native.astToString(getContext().nCtx(), getNativeObject());
}
@ -205,34 +219,30 @@ public class AST extends Z3Object
super(ctx);
}
AST(Context ctx, long obj) throws Z3Exception
AST(Context ctx, long obj)
{
super(ctx, obj);
}
void incRef(long o) throws Z3Exception
void incRef(long o)
{
// Console.WriteLine("AST IncRef()");
if (getContext() == null)
throw new Z3Exception("inc() called on null context");
if (o == 0)
throw new Z3Exception("inc() called on null AST");
getContext().ast_DRQ().incAndClear(getContext(), o);
if (getContext() == null || o == 0)
return;
getContext().getASTDRQ().incAndClear(getContext(), o);
super.incRef(o);
}
void decRef(long o) throws Z3Exception
void decRef(long o)
{
// Console.WriteLine("AST DecRef()");
if (getContext() == null)
throw new Z3Exception("dec() called on null context");
if (o == 0)
throw new Z3Exception("dec() called on null AST");
getContext().ast_DRQ().add(o);
if (getContext() == null || o == 0)
return;
getContext().getASTDRQ().add(o);
super.decRef(o);
}
static AST create(Context ctx, long obj) throws Z3Exception
static AST create(Context ctx, long obj)
{
switch (Z3_ast_kind.fromInt(Native.getAstKind(ctx.nCtx(), obj)))
{

View file

@ -19,6 +19,16 @@ package com.microsoft.z3;
class ASTDecRefQueue extends IDecRefQueue
{
public ASTDecRefQueue()
{
super();
}
public ASTDecRefQueue(int move_limit)
{
super(move_limit);
}
protected void incRef(Context ctx, long obj)
{
try

View file

@ -23,13 +23,13 @@ package com.microsoft.z3;
class ASTMap extends Z3Object
{
/**
* Checks whether the map contains the key <paramref name="k"/>. <param
* name="k">An AST</param>
* Checks whether the map contains the key {@code k}.
* @param k An AST
*
* @return True if <paramref name="k"/> is a key in the map, false
* @return True if {@code k} is a key in the map, false
* otherwise.
**/
public boolean contains(AST k) throws Z3Exception
public boolean contains(AST k)
{
return Native.astMapContains(getContext().nCtx(), getNativeObject(),
@ -37,23 +37,25 @@ class ASTMap extends Z3Object
}
/**
* Finds the value associated with the key <paramref name="k"/>. <remarks>
* This function signs an error when <paramref name="k"/> is not a key in
* the map. </remarks> <param name="k">An AST</param>
* Finds the value associated with the key {@code k}.
* Remarks: This function signs an error when {@code k} is not a key in
* the map.
* @param k An AST
*
* @throws Z3Exception
**/
public AST find(AST k) throws Z3Exception
public AST find(AST k)
{
return new AST(getContext(), Native.astMapFind(getContext().nCtx(),
getNativeObject(), k.getNativeObject()));
}
/**
* Stores or replaces a new key/value pair in the map. <param name="k">The
* key AST</param> <param name="v">The value AST</param>
* Stores or replaces a new key/value pair in the map.
* @param k The key AST
* @param v The value AST
**/
public void insert(AST k, AST v) throws Z3Exception
public void insert(AST k, AST v)
{
Native.astMapInsert(getContext().nCtx(), getNativeObject(), k.getNativeObject(),
@ -61,19 +63,18 @@ class ASTMap extends Z3Object
}
/**
* Erases the key <paramref name="k"/> from the map. <param name="k">An
* AST</param>
* Erases the key {@code k} from the map.
* @param k An AST
**/
public void erase(AST k) throws Z3Exception
public void erase(AST k)
{
Native.astMapErase(getContext().nCtx(), getNativeObject(), k.getNativeObject());
}
/**
* Removes all keys from the map.
**/
public void reset() throws Z3Exception
public void reset()
{
Native.astMapReset(getContext().nCtx(), getNativeObject());
}
@ -81,7 +82,7 @@ class ASTMap extends Z3Object
/**
* The size of the map
**/
public int size() throws Z3Exception
public int size()
{
return Native.astMapSize(getContext().nCtx(), getNativeObject());
}
@ -91,7 +92,7 @@ class ASTMap extends Z3Object
*
* @throws Z3Exception
**/
public ASTVector getKeys() throws Z3Exception
public ASTVector getKeys()
{
return new ASTVector(getContext(), Native.astMapKeys(getContext().nCtx(),
getNativeObject()));
@ -111,25 +112,25 @@ class ASTMap extends Z3Object
}
}
ASTMap(Context ctx, long obj) throws Z3Exception
ASTMap(Context ctx, long obj)
{
super(ctx, obj);
}
ASTMap(Context ctx) throws Z3Exception
ASTMap(Context ctx)
{
super(ctx, Native.mkAstMap(ctx.nCtx()));
}
void incRef(long o) throws Z3Exception
void incRef(long o)
{
getContext().astmap_DRQ().incAndClear(getContext(), o);
getContext().getASTMapDRQ().incAndClear(getContext(), o);
super.incRef(o);
}
void decRef(long o) throws Z3Exception
void decRef(long o)
{
getContext().astmap_DRQ().add(o);
getContext().getASTMapDRQ().add(o);
super.decRef(o);
}
}

View file

@ -20,31 +20,32 @@ package com.microsoft.z3;
/**
* Vectors of ASTs.
**/
class ASTVector extends Z3Object
public class ASTVector extends Z3Object
{
/**
* The size of the vector
**/
public int size() throws Z3Exception
public int size()
{
return Native.astVectorSize(getContext().nCtx(), getNativeObject());
}
/**
* Retrieves the i-th object in the vector. <remarks>May throw an
* IndexOutOfBoundsException when <paramref name="i"/> is out of
* range.</remarks> <param name="i">Index</param>
* Retrieves the i-th object in the vector.
* Remarks: May throw an {@code IndexOutOfBoundsException} when
* {@code i} is out of range.
* @param i Index
*
* @return An AST
* @throws Z3Exception
**/
public AST get(int i) throws Z3Exception
public AST get(int i)
{
return new AST(getContext(), Native.astVectorGet(getContext().nCtx(),
getNativeObject(), i));
}
public void set(int i, AST value) throws Z3Exception
public void set(int i, AST value)
{
Native.astVectorSet(getContext().nCtx(), getNativeObject(), i,
@ -52,31 +53,32 @@ class ASTVector extends Z3Object
}
/**
* Resize the vector to <paramref name="newSize"/>. <param
* name="newSize">The new size of the vector.</param>
* Resize the vector to {@code newSize}.
* @param newSize The new size of the vector.
**/
public void resize(int newSize) throws Z3Exception
public void resize(int newSize)
{
Native.astVectorResize(getContext().nCtx(), getNativeObject(), newSize);
}
/**
* Add the AST <paramref name="a"/> to the back of the vector. The size is
* increased by 1. <param name="a">An AST</param>
* Add the AST {@code a} to the back of the vector. The size is
* increased by 1.
* @param a An AST
**/
public void push(AST a) throws Z3Exception
public void push(AST a)
{
Native.astVectorPush(getContext().nCtx(), getNativeObject(), a.getNativeObject());
}
/**
* Translates all ASTs in the vector to <paramref name="ctx"/>. <param
* name="ctx">A context</param>
* Translates all ASTs in the vector to {@code ctx}.
* @param ctx A context
*
* @return A new ASTVector
* @throws Z3Exception
**/
public ASTVector translate(Context ctx) throws Z3Exception
public ASTVector translate(Context ctx)
{
return new ASTVector(getContext(), Native.astVectorTranslate(getContext()
.nCtx(), getNativeObject(), ctx.nCtx()));
@ -96,25 +98,25 @@ class ASTVector extends Z3Object
}
}
ASTVector(Context ctx, long obj) throws Z3Exception
ASTVector(Context ctx, long obj)
{
super(ctx, obj);
}
ASTVector(Context ctx) throws Z3Exception
ASTVector(Context ctx)
{
super(ctx, Native.mkAstVector(ctx.nCtx()));
}
void incRef(long o) throws Z3Exception
void incRef(long o)
{
getContext().astvector_DRQ().incAndClear(getContext(), o);
getContext().getASTVectorDRQ().incAndClear(getContext(), o);
super.incRef(o);
}
void decRef(long o) throws Z3Exception
void decRef(long o)
{
getContext().astvector_DRQ().add(o);
getContext().getASTVectorDRQ().add(o);
super.decRef(o);
}
}

View file

@ -24,13 +24,15 @@ public class AlgebraicNum extends ArithExpr
{
/**
* Return a upper bound for a given real algebraic number. The interval
* isolating the number is smaller than 1/10^<paramref name="precision"/>.
* <seealso cref="Expr.IsAlgebraicNumber"/> <param name="precision">the
* precision of the result</param>
* isolating the number is smaller than 1/10^{@code precision}.
*
* @see Expr#isAlgebraicNumber
* @param precision the precision of the result
*
* @return A numeral Expr of sort Real
* @throws Z3Exception on error
**/
public RatNum toUpper(int precision) throws Z3Exception
public RatNum toUpper(int precision)
{
return new RatNum(getContext(), Native.getAlgebraicNumberUpper(getContext()
@ -39,12 +41,15 @@ public class AlgebraicNum extends ArithExpr
/**
* Return a lower bound for the given real algebraic number. The interval
* isolating the number is smaller than 1/10^<paramref name="precision"/>.
* <seealso cref="Expr.IsAlgebraicNumber"/> <param name="precision"></param>
* isolating the number is smaller than 1/10^{@code precision}.
*
* @see Expr#isAlgebraicNumber
* @param precision precision
*
* @return A numeral Expr of sort Real
* @throws Z3Exception on error
**/
public RatNum toLower(int precision) throws Z3Exception
public RatNum toLower(int precision)
{
return new RatNum(getContext(), Native.getAlgebraicNumberLower(getContext()
@ -52,17 +57,20 @@ public class AlgebraicNum extends ArithExpr
}
/**
* Returns a string representation in decimal notation. <remarks>The result
* has at most <paramref name="precision"/> decimal places.</remarks>
* Returns a string representation in decimal notation.
* Remarks: The result has at most {@code precision} decimal places.
* @param precision precision
* @return String
* @throws Z3Exception on error
**/
public String toDecimal(int precision) throws Z3Exception
public String toDecimal(int precision)
{
return Native.getNumeralDecimalString(getContext().nCtx(), getNativeObject(),
precision);
}
AlgebraicNum(Context ctx, long obj) throws Z3Exception
AlgebraicNum(Context ctx, long obj)
{
super(ctx, obj);

View file

@ -26,7 +26,7 @@ public class ApplyResult extends Z3Object
/**
* The number of Subgoals.
**/
public int getNumSubgoals() throws Z3Exception
public int getNumSubgoals()
{
return Native.applyResultGetNumSubgoals(getContext().nCtx(),
getNativeObject());
@ -37,7 +37,7 @@ public class ApplyResult extends Z3Object
*
* @throws Z3Exception
**/
public Goal[] getSubgoals() throws Z3Exception
public Goal[] getSubgoals()
{
int n = getNumSubgoals();
Goal[] res = new Goal[n];
@ -48,13 +48,13 @@ public class ApplyResult extends Z3Object
}
/**
* Convert a model for the subgoal <paramref name="i"/> into a model for the
* original goal <code>g</code>, that the ApplyResult was obtained from.
* Convert a model for the subgoal {@code i} into a model for the
* original goal {@code g}, that the ApplyResult was obtained from.
*
* @return A model for <code>g</code>
* @return A model for {@code g}
* @throws Z3Exception
**/
public Model convertModel(int i, Model m) throws Z3Exception
public Model convertModel(int i, Model m)
{
return new Model(getContext(),
Native.applyResultConvertModel(getContext().nCtx(), getNativeObject(), i, m.getNativeObject()));
@ -74,20 +74,20 @@ public class ApplyResult extends Z3Object
}
}
ApplyResult(Context ctx, long obj) throws Z3Exception
ApplyResult(Context ctx, long obj)
{
super(ctx, obj);
}
void incRef(long o) throws Z3Exception
void incRef(long o)
{
getContext().applyResult_DRQ().incAndClear(getContext(), o);
getContext().getApplyResultDRQ().incAndClear(getContext(), o);
super.incRef(o);
}
void decRef(long o) throws Z3Exception
void decRef(long o)
{
getContext().applyResult_DRQ().add(o);
getContext().getApplyResultDRQ().add(o);
super.decRef(o);
}
}

View file

@ -19,6 +19,16 @@ package com.microsoft.z3;
class ApplyResultDecRefQueue extends IDecRefQueue
{
public ApplyResultDecRefQueue()
{
super();
}
public ApplyResultDecRefQueue(int move_limit)
{
super(move_limit);
}
protected void incRef(Context ctx, long obj)
{
try

View file

@ -22,16 +22,11 @@ package com.microsoft.z3;
**/
public class ArithExpr extends Expr
{
/**
* Constructor for ArithExpr </summary>
**/
protected ArithExpr(Context ctx)
{
super(ctx);
}
ArithExpr(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
/**
* Constructor for ArithExpr
**/
ArithExpr(Context ctx, long obj)
{
super(ctx, obj);
}
}

View file

@ -22,8 +22,8 @@ package com.microsoft.z3;
**/
public class ArithSort extends Sort
{
ArithSort(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
ArithSort(Context ctx, long obj)
{
super(ctx, obj);
}
};

View file

@ -23,16 +23,11 @@ package com.microsoft.z3;
**/
public class ArrayExpr extends Expr
{
/**
* Constructor for ArrayExpr </summary>
**/
protected ArrayExpr(Context ctx)
{
super(ctx);
}
ArrayExpr(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
/**
* Constructor for ArrayExpr
**/
ArrayExpr(Context ctx, long obj)
{
super(ctx, obj);
}
}

View file

@ -22,34 +22,38 @@ package com.microsoft.z3;
**/
public class ArraySort extends Sort
{
/**
* The domain of the array sort.
* @throws Z3Exception
**/
public Sort getDomain() throws Z3Exception
{
return Sort.create(getContext(),
Native.getArraySortDomain(getContext().nCtx(), getNativeObject()));
}
/**
* The domain of the array sort.
* @throws Z3Exception
* @throws Z3Exception on error
* @return a sort
**/
public Sort getDomain()
{
return Sort.create(getContext(),
Native.getArraySortDomain(getContext().nCtx(), getNativeObject()));
}
/**
* The range of the array sort.
* @throws Z3Exception
**/
public Sort getRange() throws Z3Exception
{
return Sort.create(getContext(),
Native.getArraySortRange(getContext().nCtx(), getNativeObject()));
}
/**
* The range of the array sort.
* @throws Z3Exception
* @throws Z3Exception on error
* @return a sort
**/
public Sort getRange()
{
return Sort.create(getContext(),
Native.getArraySortRange(getContext().nCtx(), getNativeObject()));
}
ArraySort(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
ArraySort(Context ctx, long obj)
{
super(ctx, obj);
}
ArraySort(Context ctx, Sort domain, Sort range) throws Z3Exception
{
super(ctx, Native.mkArraySort(ctx.nCtx(), domain.getNativeObject(),
range.getNativeObject()));
}
ArraySort(Context ctx, Sort domain, Sort range)
{
super(ctx, Native.mkArraySort(ctx.nCtx(), domain.getNativeObject(),
range.getNativeObject()));
}
};

View file

@ -19,6 +19,16 @@ package com.microsoft.z3;
class ASTMapDecRefQueue extends IDecRefQueue
{
public ASTMapDecRefQueue()
{
super();
}
public ASTMapDecRefQueue(int move_limit)
{
super(move_limit);
}
protected void incRef(Context ctx, long obj)
{
try

View file

@ -19,6 +19,16 @@ package com.microsoft.z3;
class ASTVectorDecRefQueue extends IDecRefQueue
{
public ASTVectorDecRefQueue()
{
super();
}
public ASTVectorDecRefQueue(int move_limit)
{
super(move_limit);
}
protected void incRef(Context ctx, long obj)
{
try

View file

@ -23,25 +23,22 @@ package com.microsoft.z3;
public class BitVecExpr extends Expr
{
/**
* The size of the sort of a bit-vector term.
* @throws Z3Exception
**/
public int getSortSize() throws Z3Exception
{
return ((BitVecSort) getSort()).getSize();
}
/**
* The size of the sort of a bit-vector term.
* @throws Z3Exception
* @throws Z3Exception on error
* @return an int
**/
public int getSortSize()
{
return ((BitVecSort) getSort()).getSize();
}
/**
* Constructor for BitVecExpr </summary>
**/
BitVecExpr(Context ctx)
{
super(ctx);
}
BitVecExpr(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
/**
* Constructor for BitVecExpr
**/
BitVecExpr(Context ctx, long obj)
{
super(ctx, obj);
}
}

View file

@ -29,7 +29,7 @@ public class BitVecNum extends BitVecExpr
*
* @throws Z3Exception
**/
public int getInt() throws Z3Exception
public int getInt()
{
Native.IntPtr res = new Native.IntPtr();
if (Native.getNumeralInt(getContext().nCtx(), getNativeObject(), res) ^ true)
@ -42,7 +42,7 @@ public class BitVecNum extends BitVecExpr
*
* @throws Z3Exception
**/
public long getLong() throws Z3Exception
public long getLong()
{
Native.LongPtr res = new Native.LongPtr();
if (Native.getNumeralInt64(getContext().nCtx(), getNativeObject(), res) ^ true)
@ -72,7 +72,7 @@ public class BitVecNum extends BitVecExpr
}
}
BitVecNum(Context ctx, long obj) throws Z3Exception
BitVecNum(Context ctx, long obj)
{
super(ctx, obj);
}

View file

@ -22,16 +22,18 @@ package com.microsoft.z3;
**/
public class BitVecSort extends Sort
{
/**
* The size of the bit-vector sort.
**/
public int getSize() throws Z3Exception
{
return Native.getBvSortSize(getContext().nCtx(), getNativeObject());
}
/**
* The size of the bit-vector sort.
* @throws Z3Exception on error
* @return an int
**/
public int getSize()
{
return Native.getBvSortSize(getContext().nCtx(), getNativeObject());
}
BitVecSort(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
BitVecSort(Context ctx, long obj)
{
super(ctx, obj);
}
};

View file

@ -22,20 +22,21 @@ package com.microsoft.z3;
**/
public class BoolExpr extends Expr
{
/**
* Constructor for BoolExpr </summary>
**/
protected BoolExpr(Context ctx)
{
super(ctx);
}
/**
* Constructor for BoolExpr
**/
protected BoolExpr(Context ctx)
{
super(ctx);
}
/**
* Constructor for BoolExpr </summary>
* @throws Z3Exception
**/
BoolExpr(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
/**
* Constructor for BoolExpr
* @throws Z3Exception
* @throws Z3Exception on error
**/
BoolExpr(Context ctx, long obj)
{
super(ctx, obj);
}
}

View file

@ -22,6 +22,6 @@ package com.microsoft.z3;
**/
public class BoolSort extends Sort
{
BoolSort(Context ctx, long obj) throws Z3Exception { super(ctx, obj); { }}
BoolSort(Context ctx) throws Z3Exception { super(ctx, Native.mkBoolSort(ctx.nCtx())); { }}
BoolSort(Context ctx, long obj) { super(ctx, obj); { }}
BoolSort(Context ctx) { super(ctx, Native.mkBoolSort(ctx.nCtx())); { }}
};

View file

@ -22,48 +22,53 @@ package com.microsoft.z3;
**/
public class Constructor extends Z3Object
{
/**
* The number of fields of the constructor.
* @throws Z3Exception
**/
public int getNumFields() throws Z3Exception
{
return n;
}
/**
* The number of fields of the constructor.
* @throws Z3Exception
* @throws Z3Exception on error
* @return an int
**/
public int getNumFields()
{
return n;
}
/**
* The function declaration of the constructor.
* @throws Z3Exception
**/
public FuncDecl ConstructorDecl() throws Z3Exception
{
Native.LongPtr constructor = new Native.LongPtr();
Native.LongPtr tester = new Native.LongPtr();
long[] accessors = new long[n];
/**
* The function declaration of the constructor.
* @throws Z3Exception
* @throws Z3Exception on error
**/
public FuncDecl ConstructorDecl()
{
Native.LongPtr constructor = new Native.LongPtr();
Native.LongPtr tester = new Native.LongPtr();
long[] accessors = new long[n];
Native.queryConstructor(getContext().nCtx(), getNativeObject(), n, constructor, tester, accessors);
return new FuncDecl(getContext(), constructor.value);
}
}
/**
* The function declaration of the tester.
* @throws Z3Exception
**/
public FuncDecl getTesterDecl() throws Z3Exception
{
Native.LongPtr constructor = new Native.LongPtr();
/**
* The function declaration of the tester.
* @throws Z3Exception
* @throws Z3Exception on error
**/
public FuncDecl getTesterDecl()
{
Native.LongPtr constructor = new Native.LongPtr();
Native.LongPtr tester = new Native.LongPtr();
long[] accessors = new long[n];
Native.queryConstructor(getContext().nCtx(), getNativeObject(), n, constructor, tester, accessors);
return new FuncDecl(getContext(), tester.value);
}
}
/**
* The function declarations of the accessors
* @throws Z3Exception
**/
public FuncDecl[] getAccessorDecls() throws Z3Exception
{
Native.LongPtr constructor = new Native.LongPtr();
/**
* The function declarations of the accessors
* @throws Z3Exception
* @throws Z3Exception on error
**/
public FuncDecl[] getAccessorDecls()
{
Native.LongPtr constructor = new Native.LongPtr();
Native.LongPtr tester = new Native.LongPtr();
long[] accessors = new long[n];
Native.queryConstructor(getContext().nCtx(), getNativeObject(), n, constructor, tester, accessors);
@ -71,39 +76,40 @@ public class Constructor extends Z3Object
for (int i = 0; i < n; i++)
t[i] = new FuncDecl(getContext(), accessors[i]);
return t;
}
}
/**
* Destructor.
**/
protected void finalize() throws Z3Exception
{
Native.delConstructor(getContext().nCtx(), getNativeObject());
}
/**
* Destructor.
* @throws Z3Exception on error
**/
protected void finalize()
{
Native.delConstructor(getContext().nCtx(), getNativeObject());
}
private int n = 0;
private int n = 0;
Constructor(Context ctx, Symbol name, Symbol recognizer,
Symbol[] fieldNames, Sort[] sorts, int[] sortRefs)
throws Z3Exception
{
super(ctx);
Constructor(Context ctx, Symbol name, Symbol recognizer,
Symbol[] fieldNames, Sort[] sorts, int[] sortRefs)
{
super(ctx);
n = AST.arrayLength(fieldNames);
n = AST.arrayLength(fieldNames);
if (n != AST.arrayLength(sorts))
throw new Z3Exception(
"Number of field names does not match number of sorts");
if (sortRefs != null && sortRefs.length != n)
throw new Z3Exception(
"Number of field names does not match number of sort refs");
if (n != AST.arrayLength(sorts))
throw new Z3Exception(
"Number of field names does not match number of sorts");
if (sortRefs != null && sortRefs.length != n)
throw new Z3Exception(
"Number of field names does not match number of sort refs");
if (sortRefs == null)
sortRefs = new int[n];
if (sortRefs == null)
sortRefs = new int[n];
setNativeObject(Native.mkConstructor(ctx.nCtx(), name.getNativeObject(),
recognizer.getNativeObject(), n, Symbol.arrayToNative(fieldNames),
Sort.arrayToNative(sorts), sortRefs));
setNativeObject(Native.mkConstructor(ctx.nCtx(), name.getNativeObject(),
recognizer.getNativeObject(), n, Symbol.arrayToNative(fieldNames),
Sort.arrayToNative(sorts), sortRefs));
}
}
}

View file

@ -22,25 +22,26 @@ package com.microsoft.z3;
**/
public class ConstructorList extends Z3Object
{
/**
* Destructor.
**/
protected void finalize() throws Z3Exception
{
Native.delConstructorList(getContext().nCtx(), getNativeObject());
}
/**
* Destructor.
* @throws Z3Exception on error
**/
protected void finalize()
{
Native.delConstructorList(getContext().nCtx(), getNativeObject());
}
ConstructorList(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
ConstructorList(Context ctx, long obj)
{
super(ctx, obj);
}
ConstructorList(Context ctx, Constructor[] constructors) throws Z3Exception
{
super(ctx);
ConstructorList(Context ctx, Constructor[] constructors)
{
super(ctx);
setNativeObject(Native.mkConstructorList(getContext().nCtx(),
(int) constructors.length,
Constructor.arrayToNative(constructors)));
}
setNativeObject(Native.mkConstructorList(getContext().nCtx(),
(int) constructors.length,
Constructor.arrayToNative(constructors)));
}
}

File diff suppressed because it is too large Load diff

View file

@ -22,16 +22,11 @@ package com.microsoft.z3;
**/
public class DatatypeExpr extends Expr
{
/**
* Constructor for DatatypeExpr </summary>
**/
protected DatatypeExpr(Context ctx)
{
super(ctx);
}
DatatypeExpr(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
/**
* Constructor for DatatypeExpr
**/
DatatypeExpr(Context ctx, long obj)
{
super(ctx, obj);
}
}

View file

@ -22,81 +22,86 @@ package com.microsoft.z3;
**/
public class DatatypeSort extends Sort
{
/**
* The number of constructors of the datatype sort.
**/
public int getNumConstructors() throws Z3Exception
{
return Native.getDatatypeSortNumConstructors(getContext().nCtx(),
getNativeObject());
}
/**
* The number of constructors of the datatype sort.
* @throws Z3Exception on error
* @return an int
**/
public int getNumConstructors()
{
return Native.getDatatypeSortNumConstructors(getContext().nCtx(),
getNativeObject());
}
/**
* The constructors.
*
* @throws Z3Exception
**/
public FuncDecl[] getConstructors() throws Z3Exception
{
int n = getNumConstructors();
FuncDecl[] res = new FuncDecl[n];
for (int i = 0; i < n; i++)
res[i] = new FuncDecl(getContext(), Native.getDatatypeSortConstructor(
getContext().nCtx(), getNativeObject(), i));
return res;
}
/**
* The constructors.
*
* @throws Z3Exception
* @throws Z3Exception on error
**/
public FuncDecl[] getConstructors()
{
int n = getNumConstructors();
FuncDecl[] res = new FuncDecl[n];
for (int i = 0; i < n; i++)
res[i] = new FuncDecl(getContext(), Native.getDatatypeSortConstructor(
getContext().nCtx(), getNativeObject(), i));
return res;
}
/**
* The recognizers.
*
* @throws Z3Exception
**/
public FuncDecl[] getRecognizers() throws Z3Exception
{
int n = getNumConstructors();
FuncDecl[] res = new FuncDecl[n];
for (int i = 0; i < n; i++)
res[i] = new FuncDecl(getContext(), Native.getDatatypeSortRecognizer(
getContext().nCtx(), getNativeObject(), i));
return res;
}
/**
* The recognizers.
*
* @throws Z3Exception
* @throws Z3Exception on error
**/
public FuncDecl[] getRecognizers()
{
int n = getNumConstructors();
FuncDecl[] res = new FuncDecl[n];
for (int i = 0; i < n; i++)
res[i] = new FuncDecl(getContext(), Native.getDatatypeSortRecognizer(
getContext().nCtx(), getNativeObject(), i));
return res;
}
/**
* The constructor accessors.
*
* @throws Z3Exception
**/
public FuncDecl[][] getAccessors() throws Z3Exception
{
/**
* The constructor accessors.
*
* @throws Z3Exception
* @throws Z3Exception on error
**/
public FuncDecl[][] getAccessors()
{
int n = getNumConstructors();
FuncDecl[][] res = new FuncDecl[n][];
for (int i = 0; i < n; i++)
{
FuncDecl fd = new FuncDecl(getContext(),
Native.getDatatypeSortConstructor(getContext().nCtx(),
getNativeObject(), i));
int ds = fd.getDomainSize();
FuncDecl[] tmp = new FuncDecl[ds];
for (int j = 0; j < ds; j++)
tmp[j] = new FuncDecl(getContext(),
Native.getDatatypeSortConstructorAccessor(getContext()
.nCtx(), getNativeObject(), i, j));
res[i] = tmp;
}
return res;
}
int n = getNumConstructors();
FuncDecl[][] res = new FuncDecl[n][];
for (int i = 0; i < n; i++)
{
FuncDecl fd = new FuncDecl(getContext(),
Native.getDatatypeSortConstructor(getContext().nCtx(),
getNativeObject(), i));
int ds = fd.getDomainSize();
FuncDecl[] tmp = new FuncDecl[ds];
for (int j = 0; j < ds; j++)
tmp[j] = new FuncDecl(getContext(),
Native.getDatatypeSortConstructorAccessor(getContext()
.nCtx(), getNativeObject(), i, j));
res[i] = tmp;
}
return res;
}
DatatypeSort(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
DatatypeSort(Context ctx, long obj)
{
super(ctx, obj);
}
DatatypeSort(Context ctx, Symbol name, Constructor[] constructors)
throws Z3Exception
{
super(ctx, Native.mkDatatype(ctx.nCtx(), name.getNativeObject(),
(int) constructors.length, arrayToNative(constructors)));
DatatypeSort(Context ctx, Symbol name, Constructor[] constructors)
{
super(ctx, Native.mkDatatype(ctx.nCtx(), name.getNativeObject(),
(int) constructors.length, arrayToNative(constructors)));
}
}
};

View file

@ -22,51 +22,83 @@ package com.microsoft.z3;
**/
public class EnumSort extends Sort
{
/**
* The function declarations of the constants in the enumeration.
**/
public FuncDecl[] getConstDecls() throws Z3Exception
{
int n = Native.getDatatypeSortNumConstructors(getContext().nCtx(), getNativeObject());
/**
* The function declarations of the constants in the enumeration.
* @throws Z3Exception on error
**/
public FuncDecl[] getConstDecls()
{
int n = Native.getDatatypeSortNumConstructors(getContext().nCtx(), getNativeObject());
FuncDecl[] t = new FuncDecl[n];
for (int i = 0; i < n; i++)
t[i] = new FuncDecl(getContext(), Native.getDatatypeSortConstructor(getContext().nCtx(), getNativeObject(), i));
return t;
}
}
/**
* Retrieves the inx'th constant declaration in the enumeration.
* @throws Z3Exception on error
**/
public FuncDecl getConstDecl(int inx)
{
return new FuncDecl(getContext(), Native.getDatatypeSortConstructor(getContext().nCtx(), getNativeObject(), inx));
}
/**
* The constants in the enumeration.
**/
public Expr[] getConsts() throws Z3Exception
{
FuncDecl[] cds = getConstDecls();
/**
* The constants in the enumeration.
* @throws Z3Exception on error
* @return an Expr[]
**/
public Expr[] getConsts()
{
FuncDecl[] cds = getConstDecls();
Expr[] t = new Expr[cds.length];
for (int i = 0; i < t.length; i++)
t[i] = getContext().mkApp(cds[i]);
return t;
}
}
/**
* Retrieves the inx'th constant in the enumeration.
* @throws Z3Exception on error
* @return an Expr
**/
public Expr getConst(int inx)
{
return getContext().mkApp(getConstDecl(inx));
}
/**
* The test predicates for the constants in the enumeration.
**/
public FuncDecl[] getTesterDecls() throws Z3Exception
{
int n = Native.getDatatypeSortNumConstructors(getContext().nCtx(), getNativeObject());
/**
* The test predicates for the constants in the enumeration.
* @throws Z3Exception on error
**/
public FuncDecl[] getTesterDecls()
{
int n = Native.getDatatypeSortNumConstructors(getContext().nCtx(), getNativeObject());
FuncDecl[] t = new FuncDecl[n];
for (int i = 0; i < n; i++)
t[i] = new FuncDecl(getContext(), Native.getDatatypeSortRecognizer(getContext().nCtx(), getNativeObject(), i));
return t;
}
}
/**
* Retrieves the inx'th tester/recognizer declaration in the enumeration.
* @throws Z3Exception on error
**/
public FuncDecl getTesterDecl(int inx)
{
return new FuncDecl(getContext(), Native.getDatatypeSortRecognizer(getContext().nCtx(), getNativeObject(), inx));
}
EnumSort(Context ctx, Symbol name, Symbol[] enumNames) throws Z3Exception
{
super(ctx);
EnumSort(Context ctx, Symbol name, Symbol[] enumNames)
{
super(ctx, 0);
int n = enumNames.length;
long[] n_constdecls = new long[n];
long[] n_testers = new long[n];
setNativeObject(Native.mkEnumerationSort(ctx.nCtx(),
name.getNativeObject(), (int) n, Symbol.arrayToNative(enumNames),
n_constdecls, n_testers));
}
int n = enumNames.length;
long[] n_constdecls = new long[n];
long[] n_testers = new long[n];
setNativeObject(Native.mkEnumerationSort(ctx.nCtx(),
name.getNativeObject(), (int) n, Symbol.arrayToNative(enumNames),
n_constdecls, n_testers));
}
};

File diff suppressed because it is too large Load diff

41
src/api/java/FPExpr.java Normal file
View file

@ -0,0 +1,41 @@
/*++
Copyright (c) 2013 Microsoft Corporation
Module Name:
FPExpr.java
Abstract:
Author:
Christoph Wintersteiger (cwinter) 2013-06-10
Notes:
--*/
package com.microsoft.z3;
/**
* FloatingPoint Expressions
*/
public class FPExpr extends Expr
{
/**
* The number of exponent bits.
* @throws Z3Exception
*/
public int getEBits() { return ((FPSort)getSort()).getEBits(); }
/**
* The number of significand bits.
* @throws Z3Exception
*/
public int getSBits() { return ((FPSort)getSort()).getSBits(); }
public FPExpr(Context ctx, long obj)
{
super(ctx, obj);
}
}

84
src/api/java/FPNum.java Normal file
View file

@ -0,0 +1,84 @@
/*++
Copyright (c) 2013 Microsoft Corporation
Module Name:
FPNum.java
Abstract:
Author:
Christoph Wintersteiger (cwinter) 2013-06-10
Notes:
--*/
package com.microsoft.z3;
/**
* FloatingPoint Numerals
*/
public class FPNum extends FPExpr
{
/**
* Retrieves the sign of a floating-point literal
* Remarks: returns true if the numeral is negative
* @throws Z3Exception
*/
public boolean getSign() {
Native.IntPtr res = new Native.IntPtr();
if (Native.fpaGetNumeralSign(getContext().nCtx(), getNativeObject(), res) ^ true)
throw new Z3Exception("Sign is not a Boolean value");
return res.value != 0;
}
/**
* The significand value of a floating-point numeral as a string
* Remarks: The significand s is always 0 &lt; s &lt; 2.0; the resulting string is long
* enough to represent the real significand precisely.
* @throws Z3Exception
**/
public String getSignificand() {
return Native.fpaGetNumeralSignificandString(getContext().nCtx(), getNativeObject());
}
/**
* Return the exponent value of a floating-point numeral as a string
* @throws Z3Exception
*/
public String getExponent() {
return Native.fpaGetNumeralExponentString(getContext().nCtx(), getNativeObject());
}
/**
* Return the exponent value of a floating-point numeral as a signed 64-bit integer
* @throws Z3Exception
*/
public long getExponentInt64() {
Native.LongPtr res = new Native.LongPtr();
if (Native.fpaGetNumeralExponentInt64(getContext().nCtx(), getNativeObject(), res) ^ true)
throw new Z3Exception("Exponent is not a 64 bit integer");
return res.value;
}
public FPNum(Context ctx, long obj)
{
super(ctx, obj);
}
/**
* Returns a string representation of the numeral.
*/
public String toString()
{
try
{
return Native.getNumeralString(getContext().nCtx(), getNativeObject());
} catch (Z3Exception e)
{
return "Z3Exception: " + e.getMessage();
}
}
}

View file

@ -0,0 +1,29 @@
/*++
Copyright (c) 2013 Microsoft Corporation
Module Name:
FPRMExpr.java
Abstract:
Author:
Christoph Wintersteiger (cwinter) 2013-06-10
Notes:
--*/
package com.microsoft.z3;
/**
* FloatingPoint RoundingMode Expressions
*/
public class FPRMExpr extends Expr
{
public FPRMExpr(Context ctx, long obj)
{
super(ctx, obj);
}
}

90
src/api/java/FPRMNum.java Normal file
View file

@ -0,0 +1,90 @@
/*++
Copyright (c) 2013 Microsoft Corporation
Module Name:
FPRMNum.java
Abstract:
Author:
Christoph Wintersteiger (cwinter) 2013-06-10
Notes:
--*/
package com.microsoft.z3;
import com.microsoft.z3.enumerations.Z3_decl_kind;
/**
* FloatingPoint RoundingMode Numerals
*/
public class FPRMNum extends FPRMExpr {
/**
* Indicates whether the term is the floating-point rounding numeral roundNearestTiesToEven
* @throws Z3Exception
* **/
public boolean isRoundNearestTiesToEven() { return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN; }
/**
* Indicates whether the term is the floating-point rounding numeral roundNearestTiesToEven
* @throws Z3Exception
*/
public boolean isRNE() { return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_EVEN; }
/**
* Indicates whether the term is the floating-point rounding numeral roundNearestTiesToAway
* @throws Z3Exception
*/
public boolean isRoundNearestTiesToAway() { return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY; }
/**
* Indicates whether the term is the floating-point rounding numeral roundNearestTiesToAway
* @throws Z3Exception
*/
public boolean isRNA() { return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_FPA_RM_NEAREST_TIES_TO_AWAY; }
/**
* Indicates whether the term is the floating-point rounding numeral roundTowardPositive
* @throws Z3Exception
*/
public boolean isRoundTowardPositive() { return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_POSITIVE; }
/**
* Indicates whether the term is the floating-point rounding numeral roundTowardPositive
* @throws Z3Exception
*/
public boolean isRTP() { return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_POSITIVE; }
/**
* Indicates whether the term is the floating-point rounding numeral roundTowardNegative
* @throws Z3Exception
*/
public boolean isRoundTowardNegative() { return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_NEGATIVE; }
/**
* Indicates whether the term is the floating-point rounding numeral roundTowardNegative
* @throws Z3Exception
*/
public boolean isRTN() { return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_NEGATIVE; }
/**
* Indicates whether the term is the floating-point rounding numeral roundTowardZero
* @throws Z3Exception
*/
public boolean isRoundTowardZero() { return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_ZERO; }
/**
* Indicates whether the term is the floating-point rounding numeral roundTowardZero
* @throws Z3Exception
*/
public boolean isRTZ() { return isApp() && getFuncDecl().getDeclKind() == Z3_decl_kind.Z3_OP_FPA_RM_TOWARD_ZERO; }
public FPRMNum(Context ctx, long obj) {
super(ctx, obj);
}
}

View file

@ -0,0 +1,35 @@
/*++
Copyright (c) 2013 Microsoft Corporation
Module Name:
FPRMExpr.java
Abstract:
Author:
Christoph Wintersteiger (cwinter) 2013-06-10
Notes:
--*/
package com.microsoft.z3;
/**
* The FloatingPoint RoundingMode sort
**/
public class FPRMSort extends Sort
{
public FPRMSort(Context ctx)
{
super(ctx, Native.mkFpaRoundingModeSort(ctx.nCtx()));
}
public FPRMSort(Context ctx, long obj)
{
super(ctx, obj);
}
}

49
src/api/java/FPSort.java Normal file
View file

@ -0,0 +1,49 @@
/*++
Copyright (c) 2013 Microsoft Corporation
Module Name:
FPSort.java
Abstract:
Author:
Christoph Wintersteiger (cwinter) 2013-06-10
Notes:
--*/
package com.microsoft.z3;
/**
* A FloatingPoint sort
**/
public class FPSort extends Sort
{
public FPSort(Context ctx, long obj)
{
super(ctx, obj);
}
public FPSort(Context ctx, int ebits, int sbits)
{
super(ctx, Native.mkFpaSort(ctx.nCtx(), ebits, sbits));
}
/**
* The number of exponent bits.
*/
public int getEBits() {
return Native.fpaGetEbits(getContext().nCtx(), getNativeObject());
}
/**
* The number of significand bits.
*/
public int getSBits() {
return Native.fpaGetEbits(getContext().nCtx(), getNativeObject());
}
}

View file

@ -22,24 +22,25 @@ package com.microsoft.z3;
**/
public class FiniteDomainSort extends Sort
{
/**
* The size of the finite domain sort.
**/
public long getSize() throws Z3Exception
{
Native.LongPtr res = new Native.LongPtr();
Native.getFiniteDomainSortSize(getContext().nCtx(), getNativeObject(), res);
return res.value;
}
/**
* The size of the finite domain sort.
* @throws Z3Exception on error
**/
public long getSize()
{
Native.LongPtr res = new Native.LongPtr();
Native.getFiniteDomainSortSize(getContext().nCtx(), getNativeObject(), res);
return res.value;
}
FiniteDomainSort(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
FiniteDomainSort(Context ctx, long obj)
{
super(ctx, obj);
}
FiniteDomainSort(Context ctx, Symbol name, long size) throws Z3Exception
{
super(ctx, Native.mkFiniteDomainSort(ctx.nCtx(), name.getNativeObject(),
size));
}
FiniteDomainSort(Context ctx, Symbol name, long size)
{
super(ctx, Native.mkFiniteDomainSort(ctx.nCtx(), name.getNativeObject(),
size));
}
}

View file

@ -28,7 +28,7 @@ public class Fixedpoint extends Z3Object
/**
* A string that describes all available fixedpoint solver parameters.
**/
public String getHelp() throws Z3Exception
public String getHelp()
{
return Native.fixedpointGetHelp(getContext().nCtx(), getNativeObject());
}
@ -38,7 +38,7 @@ public class Fixedpoint extends Z3Object
*
* @throws Z3Exception
**/
public void setParameters(Params value) throws Z3Exception
public void setParameters(Params value)
{
getContext().checkContextMatch(value);
@ -51,7 +51,7 @@ public class Fixedpoint extends Z3Object
*
* @throws Z3Exception
**/
public ParamDescrs getParameterDescriptions() throws Z3Exception
public ParamDescrs getParameterDescriptions()
{
return new ParamDescrs(getContext(), Native.fixedpointGetParamDescrs(
getContext().nCtx(), getNativeObject()));
@ -62,7 +62,7 @@ public class Fixedpoint extends Z3Object
*
* @throws Z3Exception
**/
public void add(BoolExpr ... constraints) throws Z3Exception
public void add(BoolExpr ... constraints)
{
getContext().checkContextMatch(constraints);
for (BoolExpr a : constraints)
@ -77,7 +77,7 @@ public class Fixedpoint extends Z3Object
*
* @throws Z3Exception
**/
public void registerRelation(FuncDecl f) throws Z3Exception
public void registerRelation(FuncDecl f)
{
getContext().checkContextMatch(f);
@ -90,7 +90,7 @@ public class Fixedpoint extends Z3Object
*
* @throws Z3Exception
**/
public void addRule(BoolExpr rule, Symbol name) throws Z3Exception
public void addRule(BoolExpr rule, Symbol name)
{
getContext().checkContextMatch(rule);
@ -103,7 +103,7 @@ public class Fixedpoint extends Z3Object
*
* @throws Z3Exception
**/
public void addFact(FuncDecl pred, int ... args) throws Z3Exception
public void addFact(FuncDecl pred, int ... args)
{
getContext().checkContextMatch(pred);
Native.fixedpointAddFact(getContext().nCtx(), getNativeObject(),
@ -119,7 +119,7 @@ public class Fixedpoint extends Z3Object
*
* @throws Z3Exception
**/
public Status query(BoolExpr query) throws Z3Exception
public Status query(BoolExpr query)
{
getContext().checkContextMatch(query);
@ -144,7 +144,7 @@ public class Fixedpoint extends Z3Object
*
* @throws Z3Exception
**/
public Status query(FuncDecl[] relations) throws Z3Exception
public Status query(FuncDecl[] relations)
{
getContext().checkContextMatch(relations);
@ -163,19 +163,22 @@ public class Fixedpoint extends Z3Object
}
/**
* Creates a backtracking point. <seealso cref="Pop"/>
* Creates a backtracking point.
* @see pop
**/
public void push() throws Z3Exception
public void push()
{
Native.fixedpointPush(getContext().nCtx(), getNativeObject());
}
/**
* Backtrack one backtracking point. <remarks>Note that an exception is
* thrown if Pop is called without a corresponding <code>Push</code>
* </remarks> <seealso cref="Push"/>
* Backtrack one backtracking point.
* Remarks: Note that an exception is thrown if {@code pop}
* is called without a corresponding {@code push}
*
* @see push
**/
public void pop() throws Z3Exception
public void pop()
{
Native.fixedpointPop(getContext().nCtx(), getNativeObject());
}
@ -185,7 +188,7 @@ public class Fixedpoint extends Z3Object
*
* @throws Z3Exception
**/
public void updateRule(BoolExpr rule, Symbol name) throws Z3Exception
public void updateRule(BoolExpr rule, Symbol name)
{
getContext().checkContextMatch(rule);
@ -199,7 +202,7 @@ public class Fixedpoint extends Z3Object
*
* @throws Z3Exception
**/
public Expr getAnswer() throws Z3Exception
public Expr getAnswer()
{
long ans = Native.fixedpointGetAnswer(getContext().nCtx(), getNativeObject());
return (ans == 0) ? null : Expr.create(getContext(), ans);
@ -208,7 +211,7 @@ public class Fixedpoint extends Z3Object
/**
* Retrieve explanation why fixedpoint engine returned status Unknown.
**/
public String getReasonUnknown() throws Z3Exception
public String getReasonUnknown()
{
return Native.fixedpointGetReasonUnknown(getContext().nCtx(),
@ -218,7 +221,7 @@ public class Fixedpoint extends Z3Object
/**
* Retrieve the number of levels explored for a given predicate.
**/
public int getNumLevels(FuncDecl predicate) throws Z3Exception
public int getNumLevels(FuncDecl predicate)
{
return Native.fixedpointGetNumLevels(getContext().nCtx(), getNativeObject(),
predicate.getNativeObject());
@ -229,7 +232,7 @@ public class Fixedpoint extends Z3Object
*
* @throws Z3Exception
**/
public Expr getCoverDelta(int level, FuncDecl predicate) throws Z3Exception
public Expr getCoverDelta(int level, FuncDecl predicate)
{
long res = Native.fixedpointGetCoverDelta(getContext().nCtx(),
getNativeObject(), level, predicate.getNativeObject());
@ -241,7 +244,7 @@ public class Fixedpoint extends Z3Object
* at <tt>level</tt>.
**/
public void addCover(int level, FuncDecl predicate, Expr property)
throws Z3Exception
{
Native.fixedpointAddCover(getContext().nCtx(), getNativeObject(), level,
predicate.getNativeObject(), property.getNativeObject());
@ -266,7 +269,7 @@ public class Fixedpoint extends Z3Object
* Instrument the Datalog engine on which table representation to use for
* recursive predicate.
**/
public void setPredicateRepresentation(FuncDecl f, Symbol[] kinds) throws Z3Exception
public void setPredicateRepresentation(FuncDecl f, Symbol[] kinds)
{
Native.fixedpointSetPredicateRepresentation(getContext().nCtx(),
@ -278,7 +281,7 @@ public class Fixedpoint extends Z3Object
/**
* Convert benchmark given as set of axioms, rules and queries to a string.
**/
public String toString(BoolExpr[] queries) throws Z3Exception
public String toString(BoolExpr[] queries)
{
return Native.fixedpointToString(getContext().nCtx(), getNativeObject(),
@ -290,7 +293,7 @@ public class Fixedpoint extends Z3Object
*
* @throws Z3Exception
**/
public BoolExpr[] getRules() throws Z3Exception
public BoolExpr[] getRules()
{
ASTVector v = new ASTVector(getContext(), Native.fixedpointGetRules(
@ -307,7 +310,7 @@ public class Fixedpoint extends Z3Object
*
* @throws Z3Exception
**/
public BoolExpr[] getAssertions() throws Z3Exception
public BoolExpr[] getAssertions()
{
ASTVector v = new ASTVector(getContext(), Native.fixedpointGetAssertions(
@ -319,25 +322,25 @@ public class Fixedpoint extends Z3Object
return res;
}
Fixedpoint(Context ctx, long obj) throws Z3Exception
Fixedpoint(Context ctx, long obj)
{
super(ctx, obj);
}
Fixedpoint(Context ctx) throws Z3Exception
Fixedpoint(Context ctx)
{
super(ctx, Native.mkFixedpoint(ctx.nCtx()));
}
void incRef(long o) throws Z3Exception
void incRef(long o)
{
getContext().fixedpoint_DRQ().incAndClear(getContext(), o);
getContext().getFixedpointDRQ().incAndClear(getContext(), o);
super.incRef(o);
}
void decRef(long o) throws Z3Exception
void decRef(long o)
{
getContext().fixedpoint_DRQ().add(o);
getContext().getFixedpointDRQ().add(o);
super.decRef(o);
}
}

View file

@ -19,6 +19,16 @@ package com.microsoft.z3;
class FixedpointDecRefQueue extends IDecRefQueue
{
public FixedpointDecRefQueue()
{
super();
}
public FixedpointDecRefQueue(int move_limit)
{
super(move_limit);
}
protected void incRef(Context ctx, long obj)
{
try

View file

@ -29,7 +29,7 @@ public class FuncDecl extends AST
/**
* Comparison operator.
*
* @return True if <paramref name="a"/> and <paramref name="b"/> share the
* @return True if {@code a"/> and <paramref name="b} share the
* same context and are equal, false otherwise.
**/
/* Overloaded operators are not translated. */
@ -37,7 +37,7 @@ public class FuncDecl extends AST
/**
* Comparison operator.
*
* @return True if <paramref name="a"/> and <paramref name="b"/> do not
* @return True if {@code a"/> and <paramref name="b} do not
* share the same context or are not equal, false otherwise.
**/
/* Overloaded operators are not translated. */
@ -78,7 +78,7 @@ public class FuncDecl extends AST
/**
* Returns a unique identifier for the function declaration.
**/
public int getId() throws Z3Exception
public int getId()
{
return Native.getFuncDeclId(getContext().nCtx(), getNativeObject());
}
@ -86,16 +86,16 @@ public class FuncDecl extends AST
/**
* The arity of the function declaration
**/
public int getArity() throws Z3Exception
public int getArity()
{
return Native.getArity(getContext().nCtx(), getNativeObject());
}
/**
* The size of the domain of the function declaration <seealso
* cref="Arity"/>
* The size of the domain of the function declaration
* @see getArity
**/
public int getDomainSize() throws Z3Exception
public int getDomainSize()
{
return Native.getDomainSize(getContext().nCtx(), getNativeObject());
}
@ -103,7 +103,7 @@ public class FuncDecl extends AST
/**
* The domain of the function declaration
**/
public Sort[] getDomain() throws Z3Exception
public Sort[] getDomain()
{
int n = getDomainSize();
@ -118,7 +118,7 @@ public class FuncDecl extends AST
/**
* The range of the function declaration
**/
public Sort getRange() throws Z3Exception
public Sort getRange()
{
return Sort.create(getContext(),
@ -128,7 +128,7 @@ public class FuncDecl extends AST
/**
* The kind of the function declaration.
**/
public Z3_decl_kind getDeclKind() throws Z3Exception
public Z3_decl_kind getDeclKind()
{
return Z3_decl_kind.fromInt(Native.getDeclKind(getContext().nCtx(),
getNativeObject()));
@ -137,7 +137,7 @@ public class FuncDecl extends AST
/**
* The name of the function declaration
**/
public Symbol getName() throws Z3Exception
public Symbol getName()
{
return Symbol.create(getContext(),
@ -147,7 +147,7 @@ public class FuncDecl extends AST
/**
* The number of parameters of the function declaration
**/
public int getNumParameters() throws Z3Exception
public int getNumParameters()
{
return Native.getDeclNumParameters(getContext().nCtx(), getNativeObject());
}
@ -155,7 +155,7 @@ public class FuncDecl extends AST
/**
* The parameters of the function declaration
**/
public Parameter[] getParameters() throws Z3Exception
public Parameter[] getParameters()
{
int num = getNumParameters();
@ -221,9 +221,9 @@ public class FuncDecl extends AST
private String r;
/**
* The int value of the parameter.</summary>
* The int value of the parameter.
**/
public int getInt() throws Z3Exception
public int getInt()
{
if (getParameterKind() != Z3_parameter_kind.Z3_PARAMETER_INT)
throw new Z3Exception("parameter is not an int");
@ -231,9 +231,9 @@ public class FuncDecl extends AST
}
/**
* The double value of the parameter.</summary>
* The double value of the parameter.
**/
public double getDouble() throws Z3Exception
public double getDouble()
{
if (getParameterKind() != Z3_parameter_kind.Z3_PARAMETER_DOUBLE)
throw new Z3Exception("parameter is not a double ");
@ -241,9 +241,9 @@ public class FuncDecl extends AST
}
/**
* The Symbol value of the parameter.</summary>
* The Symbol value of the parameter.
**/
public Symbol getSymbol() throws Z3Exception
public Symbol getSymbol()
{
if (getParameterKind() != Z3_parameter_kind.Z3_PARAMETER_SYMBOL)
throw new Z3Exception("parameter is not a Symbol");
@ -251,9 +251,9 @@ public class FuncDecl extends AST
}
/**
* The Sort value of the parameter.</summary>
* The Sort value of the parameter.
**/
public Sort getSort() throws Z3Exception
public Sort getSort()
{
if (getParameterKind() != Z3_parameter_kind.Z3_PARAMETER_SORT)
throw new Z3Exception("parameter is not a Sort");
@ -261,9 +261,9 @@ public class FuncDecl extends AST
}
/**
* The AST value of the parameter.</summary>
* The AST value of the parameter.
**/
public AST getAST() throws Z3Exception
public AST getAST()
{
if (getParameterKind() != Z3_parameter_kind.Z3_PARAMETER_AST)
throw new Z3Exception("parameter is not an AST");
@ -271,9 +271,9 @@ public class FuncDecl extends AST
}
/**
* The FunctionDeclaration value of the parameter.</summary>
* The FunctionDeclaration value of the parameter.
**/
public FuncDecl getFuncDecl() throws Z3Exception
public FuncDecl getFuncDecl()
{
if (getParameterKind() != Z3_parameter_kind.Z3_PARAMETER_FUNC_DECL)
throw new Z3Exception("parameter is not a function declaration");
@ -281,9 +281,9 @@ public class FuncDecl extends AST
}
/**
* The rational string value of the parameter.</summary>
* The rational string value of the parameter.
**/
public String getRational() throws Z3Exception
public String getRational()
{
if (getParameterKind() != Z3_parameter_kind.Z3_PARAMETER_RATIONAL)
throw new Z3Exception("parameter is not a rational String");
@ -293,7 +293,7 @@ public class FuncDecl extends AST
/**
* The kind of the parameter.
**/
public Z3_parameter_kind getParameterKind() throws Z3Exception
public Z3_parameter_kind getParameterKind()
{
return kind;
}
@ -341,14 +341,14 @@ public class FuncDecl extends AST
}
}
FuncDecl(Context ctx, long obj) throws Z3Exception
FuncDecl(Context ctx, long obj)
{
super(ctx, obj);
}
FuncDecl(Context ctx, Symbol name, Sort[] domain, Sort range)
throws Z3Exception
{
super(ctx, Native.mkFuncDecl(ctx.nCtx(), name.getNativeObject(),
AST.arrayLength(domain), AST.arrayToNative(domain),
@ -357,7 +357,7 @@ public class FuncDecl extends AST
}
FuncDecl(Context ctx, String prefix, Sort[] domain, Sort range)
throws Z3Exception
{
super(ctx, Native.mkFreshFuncDecl(ctx.nCtx(), prefix,
AST.arrayLength(domain), AST.arrayToNative(domain),
@ -365,7 +365,7 @@ public class FuncDecl extends AST
}
void checkNativeObject(long obj) throws Z3Exception
void checkNativeObject(long obj)
{
if (Native.getAstKind(getContext().nCtx(), obj) != Z3_ast_kind.Z3_FUNC_DECL_AST
.toInt())
@ -375,12 +375,12 @@ public class FuncDecl extends AST
}
/**
* Create expression that applies function to arguments. <param
* name="args"></param>
* Create expression that applies function to arguments.
* @param args
*
* @return
**/
public Expr apply(Expr ... args) throws Z3Exception
public Expr apply(Expr ... args)
{
getContext().checkContextMatch(args);
return Expr.create(getContext(), this, args);

View file

@ -24,173 +24,183 @@ package com.microsoft.z3;
**/
public class FuncInterp extends Z3Object
{
/**
* An Entry object represents an element in the finite map used to encode a
* function interpretation.
**/
public class Entry extends Z3Object
{
/**
* Return the (symbolic) value of this entry.
*
* @throws Z3Exception
**/
public Expr getValue() throws Z3Exception
{
return Expr.create(getContext(),
Native.funcEntryGetValue(getContext().nCtx(), getNativeObject()));
}
/**
* An Entry object represents an element in the finite map used to encode a
* function interpretation.
**/
public class Entry extends Z3Object
{
/**
* Return the (symbolic) value of this entry.
*
* @throws Z3Exception
* @throws Z3Exception on error
**/
public Expr getValue()
{
return Expr.create(getContext(),
Native.funcEntryGetValue(getContext().nCtx(), getNativeObject()));
}
/**
* The number of arguments of the entry.
**/
public int getNumArgs() throws Z3Exception
{
return Native.funcEntryGetNumArgs(getContext().nCtx(), getNativeObject());
}
/**
* The number of arguments of the entry.
* @throws Z3Exception on error
**/
public int getNumArgs()
{
return Native.funcEntryGetNumArgs(getContext().nCtx(), getNativeObject());
}
/**
* The arguments of the function entry.
*
* @throws Z3Exception
**/
public Expr[] getArgs() throws Z3Exception
{
int n = getNumArgs();
Expr[] res = new Expr[n];
for (int i = 0; i < n; i++)
res[i] = Expr.create(getContext(), Native.funcEntryGetArg(
getContext().nCtx(), getNativeObject(), i));
return res;
}
/**
* The arguments of the function entry.
*
* @throws Z3Exception
* @throws Z3Exception on error
**/
public Expr[] getArgs()
{
int n = getNumArgs();
Expr[] res = new Expr[n];
for (int i = 0; i < n; i++)
res[i] = Expr.create(getContext(), Native.funcEntryGetArg(
getContext().nCtx(), getNativeObject(), i));
return res;
}
/**
* A string representation of the function entry.
**/
public String toString()
{
try
{
int n = getNumArgs();
String res = "[";
Expr[] args = getArgs();
for (int i = 0; i < n; i++)
res += args[i] + ", ";
return res + getValue() + "]";
} catch (Z3Exception e)
{
return new String("Z3Exception: " + e.getMessage());
}
}
/**
* A string representation of the function entry.
**/
public String toString()
{
try
{
int n = getNumArgs();
String res = "[";
Expr[] args = getArgs();
for (int i = 0; i < n; i++)
res += args[i] + ", ";
return res + getValue() + "]";
} catch (Z3Exception e)
{
return new String("Z3Exception: " + e.getMessage());
}
}
Entry(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
Entry(Context ctx, long obj)
{
super(ctx, obj);
}
void incRef(long o) throws Z3Exception
{
getContext().funcEntry_DRQ().incAndClear(getContext(), o);
super.incRef(o);
}
void incRef(long o)
{
getContext().getFuncEntryDRQ().incAndClear(getContext(), o);
super.incRef(o);
}
void decRef(long o) throws Z3Exception
{
getContext().funcEntry_DRQ().add(o);
super.decRef(o);
}
};
void decRef(long o)
{
getContext().getFuncEntryDRQ().add(o);
super.decRef(o);
}
};
/**
* The number of entries in the function interpretation.
**/
public int getNumEntries() throws Z3Exception
{
return Native.funcInterpGetNumEntries(getContext().nCtx(), getNativeObject());
}
/**
* The number of entries in the function interpretation.
* @throws Z3Exception on error
* @return an int
**/
public int getNumEntries()
{
return Native.funcInterpGetNumEntries(getContext().nCtx(), getNativeObject());
}
/**
* The entries in the function interpretation
*
* @throws Z3Exception
**/
public Entry[] getEntries() throws Z3Exception
{
int n = getNumEntries();
Entry[] res = new Entry[n];
for (int i = 0; i < n; i++)
res[i] = new Entry(getContext(), Native.funcInterpGetEntry(getContext()
.nCtx(), getNativeObject(), i));
return res;
}
/**
* The entries in the function interpretation
*
* @throws Z3Exception
* @throws Z3Exception on error
**/
public Entry[] getEntries()
{
int n = getNumEntries();
Entry[] res = new Entry[n];
for (int i = 0; i < n; i++)
res[i] = new Entry(getContext(), Native.funcInterpGetEntry(getContext()
.nCtx(), getNativeObject(), i));
return res;
}
/**
* The (symbolic) `else' value of the function interpretation.
*
* @throws Z3Exception
**/
public Expr getElse() throws Z3Exception
{
return Expr.create(getContext(),
Native.funcInterpGetElse(getContext().nCtx(), getNativeObject()));
}
/**
* The (symbolic) `else' value of the function interpretation.
*
* @throws Z3Exception
* @throws Z3Exception on error
* @return an Expr
**/
public Expr getElse()
{
return Expr.create(getContext(),
Native.funcInterpGetElse(getContext().nCtx(), getNativeObject()));
}
/**
* The arity of the function interpretation
**/
public int getArity() throws Z3Exception
{
return Native.funcInterpGetArity(getContext().nCtx(), getNativeObject());
}
/**
* The arity of the function interpretation
* @throws Z3Exception on error
* @return an int
**/
public int getArity()
{
return Native.funcInterpGetArity(getContext().nCtx(), getNativeObject());
}
/**
* A string representation of the function interpretation.
**/
public String toString()
{
try
{
String res = "";
res += "[";
for (Entry e : getEntries())
{
int n = e.getNumArgs();
if (n > 1)
res += "[";
Expr[] args = e.getArgs();
for (int i = 0; i < n; i++)
{
if (i != 0)
res += ", ";
res += args[i];
}
if (n > 1)
res += "]";
res += " -> " + e.getValue() + ", ";
}
res += "else -> " + getElse();
res += "]";
return res;
} catch (Z3Exception e)
{
return new String("Z3Exception: " + e.getMessage());
}
}
/**
* A string representation of the function interpretation.
**/
public String toString()
{
try
{
String res = "";
res += "[";
for (Entry e : getEntries())
{
int n = e.getNumArgs();
if (n > 1)
res += "[";
Expr[] args = e.getArgs();
for (int i = 0; i < n; i++)
{
if (i != 0)
res += ", ";
res += args[i];
}
if (n > 1)
res += "]";
res += " -> " + e.getValue() + ", ";
}
res += "else -> " + getElse();
res += "]";
return res;
} catch (Z3Exception e)
{
return new String("Z3Exception: " + e.getMessage());
}
}
FuncInterp(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
FuncInterp(Context ctx, long obj)
{
super(ctx, obj);
}
void incRef(long o) throws Z3Exception
{
getContext().funcInterp_DRQ().incAndClear(getContext(), o);
super.incRef(o);
}
void incRef(long o)
{
getContext().getFuncInterpDRQ().incAndClear(getContext(), o);
super.incRef(o);
}
void decRef(long o) throws Z3Exception
{
getContext().funcInterp_DRQ().add(o);
super.decRef(o);
}
void decRef(long o)
{
getContext().getFuncInterpDRQ().add(o);
super.decRef(o);
}
}

View file

@ -19,6 +19,16 @@ package com.microsoft.z3;
class FuncInterpDecRefQueue extends IDecRefQueue
{
public FuncInterpDecRefQueue()
{
super();
}
public FuncInterpDecRefQueue(int move_limit)
{
super(move_limit);
}
protected void incRef(Context ctx, long obj)
{
try

View file

@ -19,6 +19,16 @@ package com.microsoft.z3;
class FuncInterpEntryDecRefQueue extends IDecRefQueue
{
public FuncInterpEntryDecRefQueue()
{
super();
}
public FuncInterpEntryDecRefQueue(int move_limit)
{
super(move_limit);
}
protected void incRef(Context ctx, long obj)
{
try

View file

@ -19,16 +19,16 @@ package com.microsoft.z3;
/**
* Global functions for Z3.
* <remarks>
* Remarks:
* This (static) class contains functions that effect the behaviour of Z3
* globally across contexts, etc.
* </remarks>
*
**/
public final class Global
{
/**
* Set a global (or module) parameter, which is shared by all Z3 contexts.
* <remarks>
* Remarks:
* When a Z3 module is initialized it will use the value of these parameters
* when Z3_params objects are not provided.
* The name of parameter can be composed of characters [a-z][A-Z], digits [0-9], '-' and '_'.
@ -36,24 +36,23 @@ public final class Global
* The parameter names are case-insensitive. The character '-' should be viewed as an "alias" for '_'.
* Thus, the following parameter names are considered equivalent: "pp.decimal-precision" and "PP.DECIMAL_PRECISION".
* This function can be used to set parameters for a specific Z3 module.
* This can be done by using <module-name>.<parameter-name>.
* This can be done by using &lt;module-name&gt;.&lt;parameter-name&gt;.
* For example:
* Z3_global_param_set('pp.decimal', 'true')
* will set the parameter "decimal" in the module "pp" to true.
* </remarks>
*
**/
public static void setParameter(String id, String value)
{
Native.globalParamSet(id, value);
Native.globalParamSet(id, value);
}
/**
* Get a global (or module) parameter.
* <remarks>
* Returns null if the parameter <param name="id">parameter id</param> does not exist.
* Remarks:
* This function cannot be invoked simultaneously from different threads without synchronization.
* The result string stored in param_value is stored in a shared location.
* </remarks>
* @return null if the parameter {@code id} does not exist.
**/
public static String getParameter(String id)
{
@ -66,13 +65,44 @@ public final class Global
/**
* Restore the value of all global (and module) parameters.
* <remarks>
* Remarks:
* This command will not affect already created objects (such as tactics and solvers)
* </remarks>
* <seealso cref="SetParameter"/>
* @see setParameter
**/
public static void resetParameters()
{
Native.globalParamResetAll();
}
Native.globalParamResetAll();
}
/**
* Enable/disable printing of warning messages to the console.
* Remarks: Note
* that this function is static and effects the behaviour of all contexts
* globally.
**/
public static void ToggleWarningMessages(boolean enabled)
{
Native.toggleWarningMessages((enabled) ? true : false);
}
/**
* Enable tracing messages tagged as `tag' when Z3 is compiled in debug mode.
*
* Remarks: It is a NOOP otherwise.
**/
public static void enableTrace(String tag)
{
Native.enableTrace(tag);
}
/**
* Disable tracing messages tagged as `tag' when Z3 is compiled in debug mode.
*
* Remarks: It is a NOOP otherwise.
**/
public static void disableTrace(String tag)
{
Native.disableTrace(tag);
}
}

View file

@ -26,13 +26,14 @@ import com.microsoft.z3.enumerations.Z3_goal_prec;
public class Goal extends Z3Object
{
/**
* The precision of the goal. <remarks> Goals can be transformed using over
* The precision of the goal.
* Remarks: Goals can be transformed using over
* and under approximations. An under approximation is applied when the
* objective is to find a model for a given goal. An over approximation is
* applied when the objective is to find a proof for a given goal.
* </remarks>
*
**/
public Z3_goal_prec getPrecision() throws Z3Exception
public Z3_goal_prec getPrecision()
{
return Z3_goal_prec.fromInt(Native.goalPrecision(getContext().nCtx(),
getNativeObject()));
@ -41,7 +42,7 @@ public class Goal extends Z3Object
/**
* Indicates whether the goal is precise.
**/
public boolean isPrecise() throws Z3Exception
public boolean isPrecise()
{
return getPrecision() == Z3_goal_prec.Z3_GOAL_PRECISE;
}
@ -49,7 +50,7 @@ public class Goal extends Z3Object
/**
* Indicates whether the goal is an under-approximation.
**/
public boolean isUnderApproximation() throws Z3Exception
public boolean isUnderApproximation()
{
return getPrecision() == Z3_goal_prec.Z3_GOAL_UNDER;
}
@ -57,7 +58,7 @@ public class Goal extends Z3Object
/**
* Indicates whether the goal is an over-approximation.
**/
public boolean isOverApproximation() throws Z3Exception
public boolean isOverApproximation()
{
return getPrecision() == Z3_goal_prec.Z3_GOAL_OVER;
}
@ -66,17 +67,17 @@ public class Goal extends Z3Object
* Indicates whether the goal is garbage (i.e., the product of over- and
* under-approximations).
**/
public boolean isGarbage() throws Z3Exception
public boolean isGarbage()
{
return getPrecision() == Z3_goal_prec.Z3_GOAL_UNDER_OVER;
}
/**
* Adds the <paramref name="constraints"/> to the given goal.
* Adds the {@code constraints} to the given goal.
*
* @throws Z3Exception
**/
public void add(BoolExpr ... constraints) throws Z3Exception
public void add(BoolExpr ... constraints)
{
getContext().checkContextMatch(constraints);
for (BoolExpr c : constraints)
@ -89,16 +90,17 @@ public class Goal extends Z3Object
/**
* Indicates whether the goal contains `false'.
**/
public boolean inconsistent() throws Z3Exception
public boolean inconsistent()
{
return Native.goalInconsistent(getContext().nCtx(), getNativeObject());
}
/**
* The depth of the goal. <remarks> This tracks how many transformations
* were applied to it. </remarks>
* The depth of the goal.
* Remarks: This tracks how many transformations
* were applied to it.
**/
public int getDepth() throws Z3Exception
public int getDepth()
{
return Native.goalDepth(getContext().nCtx(), getNativeObject());
}
@ -106,7 +108,7 @@ public class Goal extends Z3Object
/**
* Erases all formulas from the given goal.
**/
public void reset() throws Z3Exception
public void reset()
{
Native.goalReset(getContext().nCtx(), getNativeObject());
}
@ -114,7 +116,7 @@ public class Goal extends Z3Object
/**
* The number of formulas in the goal.
**/
public int size() throws Z3Exception
public int size()
{
return Native.goalSize(getContext().nCtx(), getNativeObject());
}
@ -124,7 +126,7 @@ public class Goal extends Z3Object
*
* @throws Z3Exception
**/
public BoolExpr[] getFormulas() throws Z3Exception
public BoolExpr[] getFormulas()
{
int n = size();
BoolExpr[] res = new BoolExpr[n];
@ -137,7 +139,7 @@ public class Goal extends Z3Object
/**
* The number of formulas, subformulas and terms in the goal.
**/
public int getNumExprs() throws Z3Exception
public int getNumExprs()
{
return Native.goalNumExprs(getContext().nCtx(), getNativeObject());
}
@ -146,7 +148,7 @@ public class Goal extends Z3Object
* Indicates whether the goal is empty, and it is precise or the product of
* an under approximation.
**/
public boolean isDecidedSat() throws Z3Exception
public boolean isDecidedSat()
{
return Native.goalIsDecidedSat(getContext().nCtx(), getNativeObject());
}
@ -155,29 +157,29 @@ public class Goal extends Z3Object
* Indicates whether the goal contains `false', and it is precise or the
* product of an over approximation.
**/
public boolean isDecidedUnsat() throws Z3Exception
public boolean isDecidedUnsat()
{
return Native
.goalIsDecidedUnsat(getContext().nCtx(), getNativeObject());
}
/**
* Translates (copies) the Goal to the target Context <paramref
* name="ctx"/>.
* Translates (copies) the Goal to the target Context {@code ctx}.
*
* @throws Z3Exception
**/
public Goal translate(Context ctx) throws Z3Exception
public Goal translate(Context ctx)
{
return new Goal(ctx, Native.goalTranslate(getContext().nCtx(),
getNativeObject(), ctx.nCtx()));
}
/**
* Simplifies the goal. <remarks>Essentially invokes the `simplify' tactic
* on the goal.</remarks>
* Simplifies the goal.
* Remarks: Essentially invokes the `simplify' tactic
* on the goal.
**/
public Goal simplify() throws Z3Exception
public Goal simplify()
{
Tactic t = getContext().mkTactic("simplify");
ApplyResult res = t.apply(this);
@ -189,10 +191,11 @@ public class Goal extends Z3Object
}
/**
* Simplifies the goal. <remarks>Essentially invokes the `simplify' tactic
* on the goal.</remarks>
* Simplifies the goal.
* Remarks: Essentially invokes the `simplify' tactic
* on the goal.
**/
public Goal simplify(Params p) throws Z3Exception
public Goal simplify(Params p)
{
Tactic t = getContext().mkTactic("simplify");
ApplyResult res = t.apply(this, p);
@ -219,27 +222,27 @@ public class Goal extends Z3Object
}
}
Goal(Context ctx, long obj) throws Z3Exception
Goal(Context ctx, long obj)
{
super(ctx, obj);
}
Goal(Context ctx, boolean models, boolean unsatCores, boolean proofs)
throws Z3Exception
{
super(ctx, Native.mkGoal(ctx.nCtx(), (models) ? true : false,
(unsatCores) ? true : false, (proofs) ? true : false));
}
void incRef(long o) throws Z3Exception
void incRef(long o)
{
getContext().goal_DRQ().incAndClear(getContext(), o);
getContext().getGoalDRQ().incAndClear(getContext(), o);
super.incRef(o);
}
void decRef(long o) throws Z3Exception
void decRef(long o)
{
getContext().goal_DRQ().add(o);
getContext().getGoalDRQ().add(o);
super.decRef(o);
}

View file

@ -19,6 +19,16 @@ package com.microsoft.z3;
class GoalDecRefQueue extends IDecRefQueue
{
public GoalDecRefQueue()
{
super();
}
public GoalDecRefQueue(int move_limit)
{
super(move_limit);
}
protected void incRef(Context ctx, long obj)
{
try

View file

@ -19,41 +19,53 @@ package com.microsoft.z3;
import java.util.LinkedList;
abstract class IDecRefQueue
public abstract class IDecRefQueue
{
protected Object m_lock = new Object();
protected LinkedList<Long> m_queue = new LinkedList<Long>();
protected final int m_move_limit = 1024;
protected Object m_lock = new Object();
protected LinkedList<Long> m_queue = new LinkedList<Long>();
protected int m_move_limit;
protected abstract void incRef(Context ctx, long obj);
protected abstract void decRef(Context ctx, long obj);
protected void incAndClear(Context ctx, long o)
protected IDecRefQueue()
{
incRef(ctx, o);
if (m_queue.size() >= m_move_limit)
clear(ctx);
}
m_move_limit = 1024;
}
protected void add(long o)
{
if (o == 0)
return;
protected IDecRefQueue(int move_limit)
{
m_move_limit = move_limit;
}
public void setLimit(int l) { m_move_limit = l; }
protected abstract void incRef(Context ctx, long obj);
synchronized (m_lock)
{
m_queue.add(o);
}
}
protected abstract void decRef(Context ctx, long obj);
protected void clear(Context ctx)
{
synchronized (m_lock)
{
for (Long o : m_queue)
decRef(ctx, o);
m_queue.clear();
}
}
protected void incAndClear(Context ctx, long o)
{
incRef(ctx, o);
if (m_queue.size() >= m_move_limit)
clear(ctx);
}
protected void add(long o)
{
if (o == 0)
return;
synchronized (m_lock)
{
m_queue.add(o);
}
}
protected void clear(Context ctx)
{
synchronized (m_lock)
{
for (Long o : m_queue)
decRef(ctx, o);
m_queue.clear();
}
}
}

View file

@ -21,7 +21,7 @@ package com.microsoft.z3;
public class IDisposable
{
public void dispose() throws Z3Exception
{
}
public void dispose()
{
}
}

View file

@ -22,16 +22,12 @@ package com.microsoft.z3;
**/
public class IntExpr extends ArithExpr
{
/**
* Constructor for IntExpr </summary>
**/
protected IntExpr(Context ctx) throws Z3Exception
{
super(ctx);
}
IntExpr(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
/**
* Constructor for IntExpr
* @throws Z3Exception on error
**/
IntExpr(Context ctx, long obj)
{
super(ctx, obj);
}
}

View file

@ -25,7 +25,7 @@ import java.math.BigInteger;
public class IntNum extends IntExpr
{
IntNum(Context ctx, long obj) throws Z3Exception
IntNum(Context ctx, long obj)
{
super(ctx, obj);
}
@ -33,7 +33,7 @@ public class IntNum extends IntExpr
/**
* Retrieve the int value.
**/
public int getInt() throws Z3Exception
public int getInt()
{
Native.IntPtr res = new Native.IntPtr();
if (Native.getNumeralInt(getContext().nCtx(), getNativeObject(), res) ^ true)
@ -44,7 +44,7 @@ public class IntNum extends IntExpr
/**
* Retrieve the 64-bit int value.
**/
public long getInt64() throws Z3Exception
public long getInt64()
{
Native.LongPtr res = new Native.LongPtr();
if (Native.getNumeralInt64(getContext().nCtx(), getNativeObject(), res) ^ true)
@ -55,7 +55,7 @@ public class IntNum extends IntExpr
/**
* Retrieve the BigInteger value.
**/
public BigInteger getBigInteger() throws Z3Exception
public BigInteger getBigInteger()
{
return new BigInteger(this.toString());
}

View file

@ -22,13 +22,13 @@ package com.microsoft.z3;
**/
public class IntSort extends ArithSort
{
IntSort(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
IntSort(Context ctx, long obj)
{
super(ctx, obj);
}
IntSort(Context ctx) throws Z3Exception
{
super(ctx, Native.mkIntSort(ctx.nCtx()));
}
IntSort(Context ctx)
{
super(ctx, Native.mkIntSort(ctx.nCtx()));
}
}

View file

@ -25,27 +25,28 @@ import com.microsoft.z3.enumerations.Z3_symbol_kind;
public class IntSymbol extends Symbol
{
/**
* The int value of the symbol. <remarks>Throws an exception if the symbol
* is not of int kind. </remarks>
* The int value of the symbol.
* Remarks: Throws an exception if the symbol
* is not of int kind.
**/
public int getInt() throws Z3Exception
public int getInt()
{
if (!isIntSymbol())
throw new Z3Exception("Int requested from non-Int symbol");
return Native.getSymbolInt(getContext().nCtx(), getNativeObject());
}
IntSymbol(Context ctx, long obj) throws Z3Exception
IntSymbol(Context ctx, long obj)
{
super(ctx, obj);
}
IntSymbol(Context ctx, int i) throws Z3Exception
IntSymbol(Context ctx, int i)
{
super(ctx, Native.mkIntSymbol(ctx.nCtx(), i));
}
void checkNativeObject(long obj) throws Z3Exception
void checkNativeObject(long obj)
{
if (Native.getSymbolKind(getContext().nCtx(), obj) != Z3_symbol_kind.Z3_INT_SYMBOL
.toInt())

View file

@ -20,22 +20,20 @@ package com.microsoft.z3;
import java.util.Map;
import java.lang.String;
import com.microsoft.z3.Native.IntPtr;
import com.microsoft.z3.Native.UIntArrayPtr;
import com.microsoft.z3.enumerations.Z3_lbool;
/** <summary>
/**
* The InterpolationContext is suitable for generation of interpolants.
* </summary>
* <remarks>For more information on interpolation please refer
* too the C/C++ API, which is well documented.</remarks>
*
* Remarks: For more information on interpolation please refer
* too the C/C++ API, which is well documented.
**/
public class InterpolationContext extends Context
{
/**
* Constructor.
**/
public InterpolationContext() throws Z3Exception
public InterpolationContext()
{
m_ctx = Native.mkInterpolationContext(0);
initContext();
@ -44,9 +42,11 @@ public class InterpolationContext extends Context
/**
* Constructor.
*
* <remarks><seealso cref="Context.Context(Dictionary&lt;string, string&gt;)"/></remarks>
*
* Remarks:
* @see Context#Context
**/
public InterpolationContext(Map<String, String> settings) throws Z3Exception
public InterpolationContext(Map<String, String> settings)
{
long cfg = Native.mkConfig();
for (Map.Entry<String, String> kv : settings.entrySet())
@ -58,9 +58,9 @@ public class InterpolationContext extends Context
/**
* Create an expression that marks a formula position for interpolation.
* @throws Z3Exception
* @throws Z3Exception
**/
public BoolExpr MkInterpolant(BoolExpr a) throws Z3Exception
public BoolExpr MkInterpolant(BoolExpr a)
{
checkContextMatch(a);
return new BoolExpr(this, Native.mkInterpolant(nCtx(), a.getNativeObject()));
@ -68,12 +68,12 @@ public class InterpolationContext extends Context
/**
* Computes an interpolant.
* <remarks>For more information on interpolation please refer
* Remarks: For more information on interpolation please refer
* too the function Z3_get_interpolant in the C/C++ API, which is
* well documented.</remarks>
* well documented.
* @throws Z3Exception
**/
Expr[] GetInterpolant(Expr pf, Expr pat, Params p) throws Z3Exception
public Expr[] GetInterpolant(Expr pf, Expr pat, Params p)
{
checkContextMatch(pf);
checkContextMatch(pat);
@ -89,12 +89,12 @@ public class InterpolationContext extends Context
/**
* Computes an interpolant.
* <remarks>For more information on interpolation please refer
* Remarks: For more information on interpolation please refer
* too the function Z3_compute_interpolant in the C/C++ API, which is
* well documented.</remarks>
* well documented.
* @throws Z3Exception
**/
Z3_lbool ComputeInterpolant(Expr pat, Params p, ASTVector interp, Model model) throws Z3Exception
public Z3_lbool ComputeInterpolant(Expr pat, Params p, ASTVector interp, Model model)
{
checkContextMatch(pat);
checkContextMatch(p);
@ -107,24 +107,24 @@ public class InterpolationContext extends Context
return Z3_lbool.fromInt(r);
}
/// <summary>
///
/// Return a string summarizing cumulative time used for interpolation.
/// </summary>
/// <remarks>For more information on interpolation please refer
///
/// Remarks: For more information on interpolation please refer
/// too the function Z3_interpolation_profile in the C/C++ API, which is
/// well documented.</remarks>
public String InterpolationProfile() throws Z3Exception
/// well documented.
public String InterpolationProfile()
{
return Native.interpolationProfile(nCtx());
}
/// <summary>
///
/// Checks the correctness of an interpolant.
/// </summary>
/// <remarks>For more information on interpolation please refer
///
/// Remarks: For more information on interpolation please refer
/// too the function Z3_check_interpolant in the C/C++ API, which is
/// well documented.</remarks>
public int CheckInterpolant(Expr[] cnsts, int[] parents, Expr[] interps, String error, Expr[] theory) throws Z3Exception
/// well documented.
public int CheckInterpolant(Expr[] cnsts, int[] parents, Expr[] interps, String error, Expr[] theory)
{
Native.StringPtr n_err_str = new Native.StringPtr();
int r = Native.checkInterpolant(nCtx(),
@ -139,13 +139,13 @@ public class InterpolationContext extends Context
return r;
}
/// <summary>
///
/// Reads an interpolation problem from a file.
/// </summary>
/// <remarks>For more information on interpolation please refer
///
/// Remarks: For more information on interpolation please refer
/// too the function Z3_read_interpolation_problem in the C/C++ API, which is
/// well documented.</remarks>
public int ReadInterpolationProblem(String filename, Expr[] cnsts, int[] parents, String error, Expr[] theory) throws Z3Exception
/// well documented.
public int ReadInterpolationProblem(String filename, Expr[] cnsts, int[] parents, String error, Expr[] theory)
{
Native.IntPtr n_num = new Native.IntPtr();
Native.IntPtr n_num_theory = new Native.IntPtr();
@ -170,13 +170,13 @@ public class InterpolationContext extends Context
return r;
}
/// <summary>
///
/// Writes an interpolation problem to a file.
/// </summary>
/// <remarks>For more information on interpolation please refer
///
/// Remarks: For more information on interpolation please refer
/// too the function Z3_write_interpolation_problem in the C/C++ API, which is
/// well documented.</remarks>
public void WriteInterpolationProblem(String filename, Expr[] cnsts, int[] parents, String error, Expr[] theory) throws Z3Exception
/// well documented.
public void WriteInterpolationProblem(String filename, Expr[] cnsts, int[] parents, String error, Expr[] theory)
{
Native.writeInterpolationProblem(nCtx(), cnsts.length, Expr.arrayToNative(cnsts), parents, filename, theory.length, Expr.arrayToNative(theory));
}

View file

@ -26,7 +26,7 @@ public class ListSort extends Sort
* The declaration of the nil function of this list sort.
* @throws Z3Exception
**/
public FuncDecl getNilDecl() throws Z3Exception
public FuncDecl getNilDecl()
{
return new FuncDecl(getContext(), Native.getDatatypeSortConstructor(getContext().nCtx(), getNativeObject(), 0));
}
@ -35,7 +35,7 @@ public class ListSort extends Sort
* The empty list.
* @throws Z3Exception
**/
public Expr getNil() throws Z3Exception
public Expr getNil()
{
return getContext().mkApp(getNilDecl());
}
@ -44,7 +44,7 @@ public class ListSort extends Sort
* The declaration of the isNil function of this list sort.
* @throws Z3Exception
**/
public FuncDecl getIsNilDecl() throws Z3Exception
public FuncDecl getIsNilDecl()
{
return new FuncDecl(getContext(), Native.getDatatypeSortRecognizer(getContext().nCtx(), getNativeObject(), 0));
}
@ -53,7 +53,7 @@ public class ListSort extends Sort
* The declaration of the cons function of this list sort.
* @throws Z3Exception
**/
public FuncDecl getConsDecl() throws Z3Exception
public FuncDecl getConsDecl()
{
return new FuncDecl(getContext(), Native.getDatatypeSortConstructor(getContext().nCtx(), getNativeObject(), 1));
}
@ -63,7 +63,7 @@ public class ListSort extends Sort
* @throws Z3Exception
*
**/
public FuncDecl getIsConsDecl() throws Z3Exception
public FuncDecl getIsConsDecl()
{
return new FuncDecl(getContext(), Native.getDatatypeSortRecognizer(getContext().nCtx(), getNativeObject(), 1));
}
@ -72,7 +72,7 @@ public class ListSort extends Sort
* The declaration of the head function of this list sort.
* @throws Z3Exception
**/
public FuncDecl getHeadDecl() throws Z3Exception
public FuncDecl getHeadDecl()
{
return new FuncDecl(getContext(), Native.getDatatypeSortConstructorAccessor(getContext().nCtx(), getNativeObject(), 1, 0));
}
@ -81,14 +81,14 @@ public class ListSort extends Sort
* The declaration of the tail function of this list sort.
* @throws Z3Exception
**/
public FuncDecl getTailDecl() throws Z3Exception
public FuncDecl getTailDecl()
{
return new FuncDecl(getContext(), Native.getDatatypeSortConstructorAccessor(getContext().nCtx(), getNativeObject(), 1, 1));
}
ListSort(Context ctx, Symbol name, Sort elemSort) throws Z3Exception
ListSort(Context ctx, Symbol name, Sort elemSort)
{
super(ctx);
super(ctx, 0);
Native.LongPtr inil = new Native.LongPtr(), iisnil = new Native.LongPtr();
Native.LongPtr icons = new Native.LongPtr(), iiscons = new Native.LongPtr();

View file

@ -18,17 +18,18 @@ Notes:
package com.microsoft.z3;
/**
* Interaction logging for Z3. <remarks> Note that this is a global, static log
* Interaction logging for Z3.
* Remarks: Note that this is a global, static log
* and if multiple Context objects are created, it logs the interaction with all
* of them. </remarks>
* of them.
**/
public final class Log
{
private static boolean m_is_open = false;
/**
* Open an interaction log file. <param name="filename">the name of the file
* to open</param>
* Open an interaction log file.
* @param filename the name of the file to open
*
* @return True if opening the log file succeeds, false otherwise.
**/
@ -48,11 +49,11 @@ public final class Log
}
/**
* Appends the user-provided string <paramref name="s"/> to the interaction
* Appends the user-provided string {@code s} to the interaction
* log.
* @throws Z3Exception
**/
public static void append(String s) throws Z3Exception
public static void append(String s)
{
if (!m_is_open)
throw new Z3Exception("Log cannot be closed.");

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