mirror of
https://github.com/Z3Prover/z3
synced 2025-04-22 16:45:31 +00:00
Merge branch 'pure' of https://github.com/Z3Prover/z3
Conflicts: src/api/ml/z3.ml src/api/ml/z3.mli src/api/python/z3util.py
This commit is contained in:
commit
95dea3922d
1108 changed files with 54208 additions and 8417 deletions
|
@ -47,7 +47,7 @@ extern "C" {
|
|||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_real(__in Z3_context c, int num, int den) {
|
||||
Z3_ast Z3_API Z3_mk_real(Z3_context c, int num, int den) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_real(c, num, den);
|
||||
RESET_ERROR_CODE();
|
||||
|
|
|
@ -83,7 +83,7 @@ extern "C" {
|
|||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_map(__in Z3_context c, __in Z3_func_decl f, unsigned n, __in Z3_ast const* args) {
|
||||
Z3_ast Z3_API Z3_mk_map(Z3_context c, Z3_func_decl f, unsigned n, Z3_ast const* args) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_map(c, f, n, args);
|
||||
RESET_ERROR_CODE();
|
||||
|
@ -108,7 +108,7 @@ extern "C" {
|
|||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_const_array(__in Z3_context c, __in Z3_sort domain, __in Z3_ast v) {
|
||||
Z3_ast Z3_API Z3_mk_const_array(Z3_context c, Z3_sort domain, Z3_ast v) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_const_array(c, domain, v);
|
||||
RESET_ERROR_CODE();
|
||||
|
@ -127,7 +127,7 @@ extern "C" {
|
|||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_array_default(__in Z3_context c, __in Z3_ast array) {
|
||||
Z3_ast Z3_API Z3_mk_array_default(Z3_context c, Z3_ast array) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_array_default(c, array);
|
||||
RESET_ERROR_CODE();
|
||||
|
@ -142,7 +142,7 @@ extern "C" {
|
|||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast mk_app_array_core(__in Z3_context c, __in Z3_sort domain, __in Z3_ast v) {
|
||||
Z3_ast mk_app_array_core(Z3_context c, Z3_sort domain, Z3_ast v) {
|
||||
RESET_ERROR_CODE();
|
||||
ast_manager & m = mk_c(c)->m();
|
||||
expr * _v = to_expr(v);
|
||||
|
@ -158,13 +158,13 @@ extern "C" {
|
|||
return of_ast(r);
|
||||
}
|
||||
|
||||
Z3_sort Z3_API Z3_mk_set_sort(__in Z3_context c, __in Z3_sort ty) {
|
||||
Z3_sort Z3_API Z3_mk_set_sort(Z3_context c, Z3_sort ty) {
|
||||
Z3_TRY;
|
||||
return Z3_mk_array_sort(c, ty, Z3_mk_bool_sort(c));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_empty_set(__in Z3_context c, __in Z3_sort domain) {
|
||||
Z3_ast Z3_API Z3_mk_empty_set(Z3_context c, Z3_sort domain) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_empty_set(c, domain);
|
||||
RESET_ERROR_CODE();
|
||||
|
@ -173,7 +173,7 @@ extern "C" {
|
|||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_full_set(__in Z3_context c, __in Z3_sort domain) {
|
||||
Z3_ast Z3_API Z3_mk_full_set(Z3_context c, Z3_sort domain) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_full_set(c, domain);
|
||||
RESET_ERROR_CODE();
|
||||
|
@ -188,15 +188,15 @@ extern "C" {
|
|||
MK_UNARY(Z3_mk_set_complement, mk_c(c)->get_array_fid(), OP_SET_COMPLEMENT, SKIP);
|
||||
MK_BINARY(Z3_mk_set_subset, mk_c(c)->get_array_fid(), OP_SET_SUBSET, SKIP);
|
||||
|
||||
Z3_ast Z3_mk_set_member(__in Z3_context c, __in Z3_ast elem, __in Z3_ast set) {
|
||||
Z3_ast Z3_mk_set_member(Z3_context c, Z3_ast elem, Z3_ast set) {
|
||||
return Z3_mk_select(c, set, elem);
|
||||
}
|
||||
|
||||
Z3_ast Z3_mk_set_add(__in Z3_context c, __in Z3_ast set, __in Z3_ast elem) {
|
||||
Z3_ast Z3_mk_set_add(Z3_context c, Z3_ast set, Z3_ast elem) {
|
||||
return Z3_mk_store(c, set, elem, Z3_mk_true(c));
|
||||
}
|
||||
|
||||
Z3_ast Z3_mk_set_del(__in Z3_context c, __in Z3_ast set, __in Z3_ast elem) {
|
||||
Z3_ast Z3_mk_set_del(Z3_context c, Z3_ast set, Z3_ast elem) {
|
||||
return Z3_mk_store(c, set, elem, Z3_mk_false(c));
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ Revision History:
|
|||
#include"bv_decl_plugin.h"
|
||||
#include"datatype_decl_plugin.h"
|
||||
#include"array_decl_plugin.h"
|
||||
#include"pb_decl_plugin.h"
|
||||
#include"ast_translation.h"
|
||||
#include"ast_pp.h"
|
||||
#include"ast_ll_pp.h"
|
||||
|
@ -663,12 +664,9 @@ extern "C" {
|
|||
Z3_TRY;
|
||||
LOG_Z3_get_bool_value(c, a);
|
||||
RESET_ERROR_CODE();
|
||||
CHECK_IS_EXPR(a, Z3_L_UNDEF);
|
||||
ast_manager & m = mk_c(c)->m();
|
||||
ast * n = to_ast(a);
|
||||
if (!is_expr(n)) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
return Z3_L_UNDEF;
|
||||
}
|
||||
if (m.is_true(to_expr(n)))
|
||||
return Z3_L_TRUE;
|
||||
if (m.is_false(to_expr(n)))
|
||||
|
@ -1081,7 +1079,6 @@ extern "C" {
|
|||
case OP_BSREM_I:
|
||||
case OP_BUREM_I:
|
||||
case OP_BSMOD_I:
|
||||
|
||||
return Z3_OP_UNINTERPRETED;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
|
@ -1090,9 +1087,10 @@ extern "C" {
|
|||
}
|
||||
if (mk_c(c)->get_dt_fid() == _d->get_family_id()) {
|
||||
switch(_d->get_decl_kind()) {
|
||||
case OP_DT_CONSTRUCTOR: return Z3_OP_DT_CONSTRUCTOR;
|
||||
case OP_DT_RECOGNISER: return Z3_OP_DT_RECOGNISER;
|
||||
case OP_DT_ACCESSOR: return Z3_OP_DT_ACCESSOR;
|
||||
case OP_DT_CONSTRUCTOR: return Z3_OP_DT_CONSTRUCTOR;
|
||||
case OP_DT_RECOGNISER: return Z3_OP_DT_RECOGNISER;
|
||||
case OP_DT_ACCESSOR: return Z3_OP_DT_ACCESSOR;
|
||||
case OP_DT_UPDATE_FIELD: return Z3_OP_DT_UPDATE_FIELD;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return Z3_OP_UNINTERPRETED;
|
||||
|
@ -1186,6 +1184,15 @@ extern "C" {
|
|||
}
|
||||
}
|
||||
|
||||
if (mk_c(c)->get_pb_fid() == _d->get_family_id()) {
|
||||
switch(_d->get_decl_kind()) {
|
||||
case OP_PB_LE: return Z3_OP_PB_LE;
|
||||
case OP_PB_GE: return Z3_OP_PB_GE;
|
||||
case OP_AT_MOST_K: return Z3_OP_PB_AT_MOST;
|
||||
default: UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
return Z3_OP_UNINTERPRETED;
|
||||
Z3_CATCH_RETURN(Z3_OP_UNINTERPRETED);
|
||||
}
|
||||
|
|
|
@ -15,8 +15,8 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef _API_AST_MAP_H_
|
||||
#define _API_AST_MAP_H_
|
||||
#ifndef API_AST_MAP_H_
|
||||
#define API_AST_MAP_H_
|
||||
|
||||
#include"api_util.h"
|
||||
#include"obj_hashtable.h"
|
||||
|
|
|
@ -15,8 +15,8 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef _API_AST_VECTOR_H_
|
||||
#define _API_AST_VECTOR_H_
|
||||
#ifndef API_AST_VECTOR_H_
|
||||
#define API_AST_VECTOR_H_
|
||||
|
||||
#include"api_util.h"
|
||||
|
||||
|
|
|
@ -159,7 +159,7 @@ Z3_ast Z3_API NAME(Z3_context c, unsigned i, Z3_ast n) { \
|
|||
This function is a shorthand for <tt>shl(1, N-1)</tt>
|
||||
where <tt>N</tt> are the number of bits of \c s.
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_bvmsb(__in Z3_context c, __in Z3_sort s) {
|
||||
Z3_ast Z3_API Z3_mk_bvmsb(Z3_context c, Z3_sort s) {
|
||||
Z3_TRY;
|
||||
RESET_ERROR_CODE();
|
||||
// Not logging this one, since it is just syntax sugar.
|
||||
|
@ -179,19 +179,19 @@ Z3_ast Z3_API NAME(Z3_context c, unsigned i, Z3_ast n) { \
|
|||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_mk_bvsmin(__in Z3_context c, __in Z3_sort s) {
|
||||
Z3_ast Z3_mk_bvsmin(Z3_context c, Z3_sort s) {
|
||||
return Z3_mk_bvmsb(c, s);
|
||||
}
|
||||
|
||||
Z3_ast Z3_mk_bvsmax(__in Z3_context c, __in Z3_sort s) {
|
||||
Z3_ast Z3_mk_bvsmax(Z3_context c, Z3_sort s) {
|
||||
return Z3_mk_bvnot(c, Z3_mk_bvmsb(c, s));
|
||||
}
|
||||
|
||||
Z3_ast Z3_mk_bvumax(__in Z3_context c, __in Z3_sort s) {
|
||||
Z3_ast Z3_mk_bvumax(Z3_context c, Z3_sort s) {
|
||||
return Z3_mk_int(c, -1, s);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_bvadd_no_overflow(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2, Z3_bool is_signed) {
|
||||
Z3_ast Z3_API Z3_mk_bvadd_no_overflow(Z3_context c, Z3_ast t1, Z3_ast t2, Z3_bool is_signed) {
|
||||
Z3_TRY;
|
||||
RESET_ERROR_CODE();
|
||||
if (is_signed) {
|
||||
|
@ -235,7 +235,7 @@ Z3_ast Z3_API NAME(Z3_context c, unsigned i, Z3_ast n) { \
|
|||
}
|
||||
|
||||
// only for signed machine integers
|
||||
Z3_ast Z3_API Z3_mk_bvadd_no_underflow(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2) {
|
||||
Z3_ast Z3_API Z3_mk_bvadd_no_underflow(Z3_context c, Z3_ast t1, Z3_ast t2) {
|
||||
Z3_TRY;
|
||||
RESET_ERROR_CODE();
|
||||
Z3_ast zero = Z3_mk_int(c, 0, Z3_get_sort(c, t1));
|
||||
|
@ -263,7 +263,7 @@ Z3_ast Z3_API NAME(Z3_context c, unsigned i, Z3_ast n) { \
|
|||
}
|
||||
|
||||
// only for signed machine integers
|
||||
Z3_ast Z3_API Z3_mk_bvsub_no_overflow(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2) {
|
||||
Z3_ast Z3_API Z3_mk_bvsub_no_overflow(Z3_context c, Z3_ast t1, Z3_ast t2) {
|
||||
Z3_TRY;
|
||||
RESET_ERROR_CODE();
|
||||
Z3_ast minus_t2 = Z3_mk_bvneg(c, t2);
|
||||
|
@ -291,7 +291,7 @@ Z3_ast Z3_API NAME(Z3_context c, unsigned i, Z3_ast n) { \
|
|||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_bvsub_no_underflow(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2, Z3_bool is_signed) {
|
||||
Z3_ast Z3_API Z3_mk_bvsub_no_underflow(Z3_context c, Z3_ast t1, Z3_ast t2, Z3_bool is_signed) {
|
||||
Z3_TRY;
|
||||
RESET_ERROR_CODE();
|
||||
if (is_signed) {
|
||||
|
@ -316,7 +316,7 @@ Z3_ast Z3_API NAME(Z3_context c, unsigned i, Z3_ast n) { \
|
|||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_API Z3_mk_bvmul_no_overflow(__in Z3_context c, __in Z3_ast n1, __in Z3_ast n2, Z3_bool is_signed) {
|
||||
Z3_ast Z3_API Z3_mk_bvmul_no_overflow(Z3_context c, Z3_ast n1, Z3_ast n2, Z3_bool is_signed) {
|
||||
LOG_Z3_mk_bvmul_no_overflow(c, n1, n2, is_signed);
|
||||
RESET_ERROR_CODE();
|
||||
if (is_signed) {
|
||||
|
@ -328,13 +328,13 @@ Z3_ast Z3_API NAME(Z3_context c, unsigned i, Z3_ast n) { \
|
|||
}
|
||||
|
||||
// only for signed machine integers
|
||||
Z3_ast Z3_API Z3_mk_bvmul_no_underflow(__in Z3_context c, __in Z3_ast n1, __in Z3_ast n2) {
|
||||
Z3_ast Z3_API Z3_mk_bvmul_no_underflow(Z3_context c, Z3_ast n1, Z3_ast n2) {
|
||||
LOG_Z3_mk_bvmul_no_underflow(c, n1, n2);
|
||||
MK_BINARY_BODY(Z3_mk_bvmul_no_underflow, mk_c(c)->get_bv_fid(), OP_BSMUL_NO_UDFL, SKIP);
|
||||
}
|
||||
|
||||
// only for signed machine integers
|
||||
Z3_ast Z3_API Z3_mk_bvneg_no_overflow(__in Z3_context c, __in Z3_ast t) {
|
||||
Z3_ast Z3_API Z3_mk_bvneg_no_overflow(Z3_context c, Z3_ast t) {
|
||||
Z3_TRY;
|
||||
RESET_ERROR_CODE();
|
||||
Z3_ast min = Z3_mk_bvsmin(c, Z3_get_sort(c, t));
|
||||
|
@ -346,7 +346,7 @@ Z3_ast Z3_API NAME(Z3_context c, unsigned i, Z3_ast n) { \
|
|||
}
|
||||
|
||||
// only for signed machine integers
|
||||
Z3_ast Z3_API Z3_mk_bvsdiv_no_overflow(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2) {
|
||||
Z3_ast Z3_API Z3_mk_bvsdiv_no_overflow(Z3_context c, Z3_ast t1, Z3_ast t2) {
|
||||
Z3_TRY;
|
||||
RESET_ERROR_CODE();
|
||||
Z3_sort s = Z3_get_sort(c, t1);
|
||||
|
|
|
@ -37,9 +37,7 @@ extern "C" {
|
|||
catch (z3_exception & ex) {
|
||||
// The error handler is only available for contexts
|
||||
// Just throw a warning.
|
||||
std::ostringstream buffer;
|
||||
buffer << "Error setting " << param_id << ", " << ex.msg();
|
||||
warning_msg(buffer.str().c_str());
|
||||
warning_msg(ex.msg());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,9 +62,7 @@ extern "C" {
|
|||
catch (z3_exception & ex) {
|
||||
// The error handler is only available for contexts
|
||||
// Just throw a warning.
|
||||
std::ostringstream buffer;
|
||||
buffer << "Error setting " << param_id << ": " << ex.msg();
|
||||
warning_msg(buffer.str().c_str());
|
||||
warning_msg(ex.msg());
|
||||
return Z3_FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -92,9 +88,7 @@ extern "C" {
|
|||
catch (z3_exception & ex) {
|
||||
// The error handler is only available for contexts
|
||||
// Just throw a warning.
|
||||
std::ostringstream buffer;
|
||||
buffer << "Error setting " << param_id << ": " << ex.msg();
|
||||
warning_msg(buffer.str().c_str());
|
||||
warning_msg(ex.msg());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ namespace api {
|
|||
m_bv_util(m()),
|
||||
m_datalog_util(m()),
|
||||
m_fpa_util(m()),
|
||||
m_dtutil(m()),
|
||||
m_dtutil(m()),
|
||||
m_last_result(m()),
|
||||
m_ast_trail(m()),
|
||||
m_replay_stack() {
|
||||
|
@ -111,6 +111,7 @@ namespace api {
|
|||
m_basic_fid = m().get_basic_family_id();
|
||||
m_arith_fid = m().mk_family_id("arith");
|
||||
m_bv_fid = m().mk_family_id("bv");
|
||||
m_pb_fid = m().mk_family_id("pb");
|
||||
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");
|
||||
|
@ -515,6 +516,11 @@ extern "C" {
|
|||
memory::initialize(0);
|
||||
}
|
||||
|
||||
void Z3_API Z3_finalize_memory(void) {
|
||||
LOG_Z3_finalize_memory();
|
||||
memory::finalize();
|
||||
}
|
||||
|
||||
Z3_error_code Z3_API Z3_get_error_code(Z3_context c) {
|
||||
LOG_Z3_get_error_code(c);
|
||||
return mk_c(c)->get_error_code();
|
||||
|
@ -526,7 +532,7 @@ extern "C" {
|
|||
// [Leo]: using exception handling, we don't need global error handlers anymore
|
||||
}
|
||||
|
||||
void Z3_API Z3_set_error(__in Z3_context c, __in Z3_error_code e) {
|
||||
void Z3_API Z3_set_error(Z3_context c, Z3_error_code e) {
|
||||
SET_ERROR_CODE(e);
|
||||
}
|
||||
|
||||
|
@ -578,7 +584,7 @@ extern "C" {
|
|||
|
||||
};
|
||||
|
||||
Z3_API ast_manager& Z3_get_manager(__in Z3_context c) {
|
||||
Z3_API ast_manager& Z3_get_manager(Z3_context c) {
|
||||
return mk_c(c)->m();
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef _API_CONTEXT_H_
|
||||
#define _API_CONTEXT_H_
|
||||
#ifndef API_CONTEXT_H_
|
||||
#define API_CONTEXT_H_
|
||||
|
||||
#include"z3.h"
|
||||
#include"ast.h"
|
||||
|
@ -78,6 +78,7 @@ namespace api {
|
|||
family_id m_bv_fid;
|
||||
family_id m_dt_fid;
|
||||
family_id m_datalog_fid;
|
||||
family_id m_pb_fid;
|
||||
family_id m_fpa_fid;
|
||||
datatype_decl_plugin * m_dt_plugin;
|
||||
|
||||
|
@ -116,6 +117,7 @@ namespace api {
|
|||
bool produce_unsat_cores() const { return m_params.m_unsat_core; }
|
||||
bool use_auto_config() const { return m_params.m_auto_config; }
|
||||
unsigned get_timeout() const { return m_params.m_timeout; }
|
||||
unsigned get_rlimit() const { return m_params.m_rlimit; }
|
||||
arith_util & autil() { return m_arith_util; }
|
||||
bv_util & bvutil() { return m_bv_util; }
|
||||
datalog::dl_decl_util & datalog_util() { return m_datalog_util; }
|
||||
|
@ -127,6 +129,7 @@ namespace api {
|
|||
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_pb_fid() const { return m_pb_fid; }
|
||||
family_id get_fpa_fid() const { return m_fpa_fid; }
|
||||
datatype_decl_plugin * get_dt_plugin() const { return m_dt_plugin; }
|
||||
|
||||
|
@ -242,6 +245,7 @@ inline api::context * mk_c(Z3_context c) { return reinterpret_cast<api::context*
|
|||
#define CHECK_VALID_AST(_a_, _ret_) { if (_a_ == 0 || !CHECK_REF_COUNT(_a_)) { SET_ERROR_CODE(Z3_INVALID_ARG); return _ret_; } }
|
||||
#define CHECK_SEARCHING(c) mk_c(c)->check_searching();
|
||||
inline bool is_expr(Z3_ast a) { return is_expr(to_ast(a)); }
|
||||
#define CHECK_IS_EXPR(_p_, _ret_) { if (!is_expr(_p_)) { SET_ERROR_CODE(Z3_INVALID_ARG); return _ret_; } }
|
||||
inline bool is_bool_expr(Z3_context c, Z3_ast a) { return is_expr(a) && mk_c(c)->m().is_bool(to_expr(a)); }
|
||||
#define CHECK_FORMULA(_a_, _ret_) { if (_a_ == 0 || !CHECK_REF_COUNT(_a_) || !is_bool_expr(c, _a_)) { SET_ERROR_CODE(Z3_INVALID_ARG); return _ret_; } }
|
||||
inline void check_sorts(Z3_context c, ast * n) { mk_c(c)->check_sorts(n); }
|
||||
|
|
|
@ -125,7 +125,7 @@ namespace api {
|
|||
return "unknown";
|
||||
}
|
||||
}
|
||||
std::string to_string(unsigned num_queries, expr*const* queries) {
|
||||
std::string to_string(unsigned num_queries, expr* const* queries) {
|
||||
std::stringstream str;
|
||||
m_context.display_smt2(num_queries, queries, str);
|
||||
return str.str();
|
||||
|
@ -287,9 +287,11 @@ extern "C" {
|
|||
lbool r = l_undef;
|
||||
cancel_eh<api::fixedpoint_context> eh(*to_fixedpoint_ref(d));
|
||||
unsigned timeout = to_fixedpoint(d)->m_params.get_uint("timeout", mk_c(c)->get_timeout());
|
||||
unsigned rlimit = to_fixedpoint(d)->m_params.get_uint("rlimit", mk_c(c)->get_rlimit());
|
||||
api::context::set_interruptable si(*(mk_c(c)), eh);
|
||||
{
|
||||
scoped_timer timer(timeout, &eh);
|
||||
scoped_rlimit _rlimit(mk_c(c)->m().limit(), rlimit);
|
||||
try {
|
||||
r = to_fixedpoint_ref(d)->ctx().query(to_expr(q));
|
||||
}
|
||||
|
@ -304,8 +306,8 @@ extern "C" {
|
|||
}
|
||||
|
||||
Z3_lbool Z3_API Z3_fixedpoint_query_relations(
|
||||
__in Z3_context c,__in Z3_fixedpoint d,
|
||||
__in unsigned num_relations, Z3_func_decl const relations[]) {
|
||||
Z3_context c,Z3_fixedpoint d,
|
||||
unsigned num_relations, Z3_func_decl const relations[]) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_fixedpoint_query_relations(c, d, num_relations, relations);
|
||||
RESET_ERROR_CODE();
|
||||
|
@ -466,13 +468,16 @@ extern "C" {
|
|||
ast_manager& m = mk_c(c)->m();
|
||||
Z3_ast_vector_ref* v = alloc(Z3_ast_vector_ref, m);
|
||||
mk_c(c)->save_object(v);
|
||||
expr_ref_vector rules(m);
|
||||
expr_ref_vector rules(m), queries(m);
|
||||
svector<symbol> names;
|
||||
|
||||
to_fixedpoint_ref(d)->ctx().get_rules_as_formulas(rules, names);
|
||||
to_fixedpoint_ref(d)->ctx().get_rules_as_formulas(rules, queries, names);
|
||||
for (unsigned i = 0; i < rules.size(); ++i) {
|
||||
v->m_ast_vector.push_back(rules[i].get());
|
||||
}
|
||||
for (unsigned i = 0; i < queries.size(); ++i) {
|
||||
v->m_ast_vector.push_back(m.mk_not(queries[i].get()));
|
||||
}
|
||||
RETURN_Z3(of_ast_vector(v));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef _API_DATALOG_H_
|
||||
#define _API_DATALOG_H_
|
||||
#ifndef API_DATALOG_H_
|
||||
#define API_DATALOG_H_
|
||||
|
||||
#include"z3.h"
|
||||
#include"ast.h"
|
||||
|
|
|
@ -476,7 +476,7 @@ extern "C" {
|
|||
return 0;
|
||||
}
|
||||
ptr_vector<func_decl> const * decls = dt_util.get_datatype_constructors(_t);
|
||||
if (idx >= decls->size()) {
|
||||
if (!decls || idx >= decls->size()) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
return 0;
|
||||
}
|
||||
|
@ -506,9 +506,9 @@ extern "C" {
|
|||
RETURN_Z3(0);
|
||||
}
|
||||
ptr_vector<func_decl> const * decls = dt_util.get_datatype_constructors(_t);
|
||||
if (idx >= decls->size()) {
|
||||
if (!decls || idx >= decls->size()) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
return 0;
|
||||
RETURN_Z3(0);
|
||||
}
|
||||
func_decl* decl = (*decls)[idx];
|
||||
decl = dt_util.get_constructor_recognizer(decl);
|
||||
|
@ -529,7 +529,7 @@ extern "C" {
|
|||
RETURN_Z3(0);
|
||||
}
|
||||
ptr_vector<func_decl> const * decls = dt_util.get_datatype_constructors(_t);
|
||||
if (idx_c >= decls->size()) {
|
||||
if (!decls || idx_c >= decls->size()) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
return 0;
|
||||
}
|
||||
|
@ -618,4 +618,25 @@ extern "C" {
|
|||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_ast Z3_datatype_update_field(
|
||||
Z3_context c, Z3_func_decl f, Z3_ast t, Z3_ast v) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_datatype_update_field(c, f, t, v);
|
||||
RESET_ERROR_CODE();
|
||||
ast_manager & m = mk_c(c)->m();
|
||||
func_decl* _f = to_func_decl(f);
|
||||
expr* _t = to_expr(t);
|
||||
expr* _v = to_expr(v);
|
||||
expr* args[2] = { _t, _v };
|
||||
sort* domain[2] = { m.get_sort(_t), m.get_sort(_v) };
|
||||
parameter param(_f);
|
||||
func_decl * d = m.mk_func_decl(mk_c(c)->get_array_fid(), OP_DT_UPDATE_FIELD, 1, ¶m, 2, domain);
|
||||
app* r = m.mk_app(d, 2, args);
|
||||
mk_c(c)->save_ast_trail(r);
|
||||
check_sorts(c, r);
|
||||
RETURN_Z3(of_ast(r));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -712,7 +712,7 @@ extern "C" {
|
|||
|
||||
unsigned Z3_API Z3_fpa_get_sbits(Z3_context c, Z3_sort s) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_fpa_get_ebits(c, s);
|
||||
LOG_Z3_fpa_get_sbits(c, s);
|
||||
RESET_ERROR_CODE();
|
||||
CHECK_NON_NULL(s, 0);
|
||||
return mk_c(c)->fpautil().get_sbits(to_sort(s));
|
||||
|
@ -737,7 +737,7 @@ extern "C" {
|
|||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_string Z3_API Z3_fpa_get_numeral_significand_string(__in Z3_context c, __in Z3_ast t) {
|
||||
Z3_string Z3_API Z3_fpa_get_numeral_significand_string(Z3_context c, Z3_ast t) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_fpa_get_numeral_significand_string(c, t);
|
||||
RESET_ERROR_CODE();
|
||||
|
@ -765,10 +765,33 @@ extern "C" {
|
|||
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_bool Z3_API Z3_fpa_get_numeral_significand_uint64(Z3_context c, Z3_ast t, __uint64 * n) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_fpa_get_numeral_significand_uint64(c, t, n);
|
||||
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();
|
||||
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;
|
||||
}
|
||||
const mpz & z = mpfm.sig(val);
|
||||
if (!mpzm.is_uint64(z)) {
|
||||
SET_ERROR_CODE(Z3_INVALID_ARG);
|
||||
return 0;
|
||||
}
|
||||
*n = mpzm.get_uint64(z);
|
||||
return 1;
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_string Z3_API Z3_fpa_get_numeral_exponent_string(Z3_context c, Z3_ast t) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_fpa_get_numeral_exponent_string(c, t);
|
||||
RESET_ERROR_CODE();
|
||||
|
@ -792,9 +815,9 @@ extern "C" {
|
|||
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_bool Z3_API Z3_fpa_get_numeral_exponent_int64(Z3_context c, Z3_ast t, __int64 * n) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_fpa_get_numeral_exponent_string(c, t);
|
||||
LOG_Z3_fpa_get_numeral_exponent_int64(c, t, n);
|
||||
RESET_ERROR_CODE();
|
||||
ast_manager & m = mk_c(c)->m();
|
||||
mpf_manager & mpfm = mk_c(c)->fpautil().fm();
|
||||
|
@ -815,7 +838,7 @@ extern "C" {
|
|||
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)));
|
||||
Z3_ast r = of_ast(ctx->fpautil().mk_to_ieee_bv(to_expr(t)));
|
||||
RETURN_Z3(r);
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
|
|
@ -15,8 +15,8 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef _API_GOAL_H_
|
||||
#define _API_GOAL_H_
|
||||
#ifndef API_GOAL_H_
|
||||
#define API_GOAL_H_
|
||||
|
||||
#include"api_util.h"
|
||||
#include"goal.h"
|
||||
|
|
|
@ -207,7 +207,7 @@ extern "C" {
|
|||
opts->map[name] = value;
|
||||
}
|
||||
|
||||
Z3_ast_vector Z3_API Z3_get_interpolant(__in Z3_context c, __in Z3_ast pf, __in Z3_ast pat, __in Z3_params p){
|
||||
Z3_ast_vector Z3_API Z3_get_interpolant(Z3_context c, Z3_ast pf, Z3_ast pat, Z3_params p){
|
||||
Z3_TRY;
|
||||
LOG_Z3_get_interpolant(c, pf, pat, p);
|
||||
RESET_ERROR_CODE();
|
||||
|
@ -240,7 +240,7 @@ extern "C" {
|
|||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_lbool Z3_API Z3_compute_interpolant(__in Z3_context c, __in Z3_ast pat, __in Z3_params p, __out Z3_ast_vector *out_interp, __out Z3_model *model){
|
||||
Z3_lbool Z3_API Z3_compute_interpolant(Z3_context c, Z3_ast pat, Z3_params p, Z3_ast_vector *out_interp, Z3_model *model){
|
||||
Z3_TRY;
|
||||
LOG_Z3_compute_interpolant(c, pat, p, out_interp, model);
|
||||
RESET_ERROR_CODE();
|
||||
|
@ -290,10 +290,10 @@ extern "C" {
|
|||
}
|
||||
}
|
||||
else {
|
||||
model_ref _m;
|
||||
m_solver.get()->get_model(_m);
|
||||
model_ref mr;
|
||||
m_solver.get()->get_model(mr);
|
||||
Z3_model_ref *tmp_val = alloc(Z3_model_ref);
|
||||
tmp_val->m_model = _m.get();
|
||||
tmp_val->m_model = mr.get();
|
||||
mk_c(c)->save_object(tmp_val);
|
||||
*model = of_model(tmp_val);
|
||||
}
|
||||
|
@ -708,15 +708,15 @@ extern "C" {
|
|||
def_API('Z3_interpolate', BOOL, (_in(CONTEXT), _in(UINT), _in_array(1, AST), _in_array(1, UINT), _in(PARAMS), _out_array(1, AST), _out(MODEL), _out(LITERALS), _in(UINT), _in(UINT), _in_array(9, AST)))
|
||||
*/
|
||||
|
||||
Z3_lbool Z3_API Z3_interpolate(__in Z3_context ctx,
|
||||
__in unsigned num,
|
||||
__in_ecount(num) Z3_ast *cnsts,
|
||||
__in_ecount(num) unsigned *parents,
|
||||
__in Z3_params options,
|
||||
__out_ecount(num - 1) Z3_ast *interps,
|
||||
__out Z3_model *model,
|
||||
__out Z3_literals *labels,
|
||||
__in unsigned incremental,
|
||||
__in unsigned num_theory,
|
||||
__in_ecount(num_theory) Z3_ast *theory);
|
||||
Z3_lbool Z3_API Z3_interpolate(Z3_context ctx,
|
||||
unsigned num,
|
||||
Z3_ast *cnsts,
|
||||
unsigned *parents,
|
||||
Z3_params options,
|
||||
Z3_ast *interps,
|
||||
Z3_model *model,
|
||||
Z3_literals *labels,
|
||||
unsigned incremental,
|
||||
unsigned num_theory,
|
||||
Z3_ast *theory);
|
||||
#endif
|
||||
|
|
|
@ -153,6 +153,7 @@ extern "C" {
|
|||
if (v) *v = 0;
|
||||
RESET_ERROR_CODE();
|
||||
CHECK_NON_NULL(m, Z3_FALSE);
|
||||
CHECK_IS_EXPR(t, Z3_FALSE);
|
||||
model * _m = to_model_ref(m);
|
||||
expr_ref result(mk_c(c)->m());
|
||||
_m->eval(to_expr(t), result, model_completion == Z3_TRUE);
|
||||
|
|
|
@ -15,8 +15,8 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef _API_MODEL_H_
|
||||
#define _API_MODEL_H_
|
||||
#ifndef API_MODEL_H_
|
||||
#define API_MODEL_H_
|
||||
|
||||
#include"api_util.h"
|
||||
#include"model.h"
|
||||
|
|
251
src/api/api_opt.cpp
Normal file
251
src/api/api_opt.cpp
Normal file
|
@ -0,0 +1,251 @@
|
|||
/*++
|
||||
Copyright (c) 2013 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
api_opt.cpp
|
||||
|
||||
Abstract:
|
||||
API for optimization
|
||||
|
||||
Author:
|
||||
|
||||
Nikolaj Bjorner (nbjorner) 2013-12-3.
|
||||
|
||||
Revision History:
|
||||
|
||||
--*/
|
||||
#include<iostream>
|
||||
#include"z3.h"
|
||||
#include"api_log_macros.h"
|
||||
#include"api_stats.h"
|
||||
#include"api_context.h"
|
||||
#include"api_util.h"
|
||||
#include"api_model.h"
|
||||
#include"opt_context.h"
|
||||
#include"cancel_eh.h"
|
||||
#include"scoped_timer.h"
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
||||
struct Z3_optimize_ref : public api::object {
|
||||
opt::context* m_opt;
|
||||
Z3_optimize_ref():m_opt(0) {}
|
||||
virtual ~Z3_optimize_ref() { dealloc(m_opt); }
|
||||
};
|
||||
inline Z3_optimize_ref * to_optimize(Z3_optimize o) { return reinterpret_cast<Z3_optimize_ref *>(o); }
|
||||
inline Z3_optimize of_optimize(Z3_optimize_ref * o) { return reinterpret_cast<Z3_optimize>(o); }
|
||||
inline opt::context* to_optimize_ptr(Z3_optimize o) { return to_optimize(o)->m_opt; }
|
||||
|
||||
Z3_optimize Z3_API Z3_mk_optimize(Z3_context c) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_optimize(c);
|
||||
RESET_ERROR_CODE();
|
||||
Z3_optimize_ref * o = alloc(Z3_optimize_ref);
|
||||
o->m_opt = alloc(opt::context,mk_c(c)->m());
|
||||
mk_c(c)->save_object(o);
|
||||
RETURN_Z3(of_optimize(o));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
void Z3_API Z3_optimize_inc_ref(Z3_context c, Z3_optimize o) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_optimize_inc_ref(c, o);
|
||||
RESET_ERROR_CODE();
|
||||
to_optimize(o)->inc_ref();
|
||||
Z3_CATCH;
|
||||
}
|
||||
|
||||
void Z3_API Z3_optimize_dec_ref(Z3_context c, Z3_optimize o) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_optimize_dec_ref(c, o);
|
||||
RESET_ERROR_CODE();
|
||||
to_optimize(o)->dec_ref();
|
||||
Z3_CATCH;
|
||||
}
|
||||
|
||||
void Z3_API Z3_optimize_assert(Z3_context c, Z3_optimize o, Z3_ast a) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_optimize_assert(c, o, a);
|
||||
RESET_ERROR_CODE();
|
||||
CHECK_FORMULA(a,);
|
||||
to_optimize_ptr(o)->add_hard_constraint(to_expr(a));
|
||||
Z3_CATCH;
|
||||
}
|
||||
|
||||
unsigned Z3_API Z3_optimize_assert_soft(Z3_context c, Z3_optimize o, Z3_ast a, Z3_string weight, Z3_symbol id) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_optimize_assert_soft(c, o, a, weight, id);
|
||||
RESET_ERROR_CODE();
|
||||
CHECK_FORMULA(a,0);
|
||||
rational w(weight);
|
||||
return to_optimize_ptr(o)->add_soft_constraint(to_expr(a), w, to_symbol(id));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
unsigned Z3_API Z3_optimize_maximize(Z3_context c, Z3_optimize o, Z3_ast t) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_optimize_maximize(c, o, t);
|
||||
RESET_ERROR_CODE();
|
||||
CHECK_VALID_AST(t,0);
|
||||
return to_optimize_ptr(o)->add_objective(to_app(t), true);
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
unsigned Z3_API Z3_optimize_minimize(Z3_context c, Z3_optimize o, Z3_ast t) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_optimize_minimize(c, o, t);
|
||||
RESET_ERROR_CODE();
|
||||
CHECK_VALID_AST(t,0);
|
||||
return to_optimize_ptr(o)->add_objective(to_app(t), false);
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
void Z3_API Z3_optimize_push(Z3_context c,Z3_optimize d) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_optimize_push(c, d);
|
||||
RESET_ERROR_CODE();
|
||||
to_optimize_ptr(d)->push();
|
||||
Z3_CATCH;
|
||||
}
|
||||
|
||||
void Z3_API Z3_optimize_pop(Z3_context c,Z3_optimize d) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_optimize_pop(c, d);
|
||||
RESET_ERROR_CODE();
|
||||
to_optimize_ptr(d)->pop(1);
|
||||
Z3_CATCH;
|
||||
}
|
||||
|
||||
|
||||
Z3_lbool Z3_API Z3_optimize_check(Z3_context c, Z3_optimize o) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_optimize_check(c, o);
|
||||
RESET_ERROR_CODE();
|
||||
lbool r = l_undef;
|
||||
cancel_eh<opt::context> eh(*to_optimize_ptr(o));
|
||||
unsigned timeout = to_optimize_ptr(o)->get_params().get_uint("timeout", mk_c(c)->get_timeout());
|
||||
api::context::set_interruptable si(*(mk_c(c)), eh);
|
||||
{
|
||||
scoped_timer timer(timeout, &eh);
|
||||
try {
|
||||
r = to_optimize_ptr(o)->optimize();
|
||||
}
|
||||
catch (z3_exception& ex) {
|
||||
mk_c(c)->handle_exception(ex);
|
||||
r = l_undef;
|
||||
}
|
||||
// to_optimize_ref(d).cleanup();
|
||||
}
|
||||
return of_lbool(r);
|
||||
Z3_CATCH_RETURN(Z3_L_UNDEF);
|
||||
}
|
||||
|
||||
Z3_string Z3_API Z3_optimize_get_reason_unknown(Z3_context c, Z3_optimize o) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_optimize_to_string(c, o);
|
||||
RESET_ERROR_CODE();
|
||||
return mk_c(c)->mk_external_string(to_optimize_ptr(o)->reason_unknown());
|
||||
Z3_CATCH_RETURN("");
|
||||
}
|
||||
|
||||
Z3_model Z3_API Z3_optimize_get_model(Z3_context c, Z3_optimize o) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_optimize_get_model(c, o);
|
||||
RESET_ERROR_CODE();
|
||||
model_ref _m;
|
||||
to_optimize_ptr(o)->get_model(_m);
|
||||
Z3_model_ref * m_ref = alloc(Z3_model_ref);
|
||||
if (_m) {
|
||||
m_ref->m_model = _m;
|
||||
}
|
||||
else {
|
||||
m_ref->m_model = alloc(model, mk_c(c)->m());
|
||||
}
|
||||
mk_c(c)->save_object(m_ref);
|
||||
RETURN_Z3(of_model(m_ref));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
void Z3_API Z3_optimize_set_params(Z3_context c, Z3_optimize o, Z3_params p) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_optimize_set_params(c, o, p);
|
||||
RESET_ERROR_CODE();
|
||||
param_descrs descrs;
|
||||
to_optimize_ptr(o)->collect_param_descrs(descrs);
|
||||
to_params(p)->m_params.validate(descrs);
|
||||
params_ref pr = to_param_ref(p);
|
||||
to_optimize_ptr(o)->updt_params(pr);
|
||||
Z3_CATCH;
|
||||
}
|
||||
|
||||
Z3_param_descrs Z3_API Z3_optimize_get_param_descrs(Z3_context c, Z3_optimize o) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_optimize_get_param_descrs(c, o);
|
||||
RESET_ERROR_CODE();
|
||||
Z3_param_descrs_ref * d = alloc(Z3_param_descrs_ref);
|
||||
mk_c(c)->save_object(d);
|
||||
to_optimize_ptr(o)->collect_param_descrs(d->m_descrs);
|
||||
Z3_param_descrs r = of_param_descrs(d);
|
||||
RETURN_Z3(r);
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
// get lower value or current approximation
|
||||
Z3_ast Z3_API Z3_optimize_get_lower(Z3_context c, Z3_optimize o, unsigned idx) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_optimize_get_lower(c, o, idx);
|
||||
RESET_ERROR_CODE();
|
||||
expr_ref e = to_optimize_ptr(o)->get_lower(idx);
|
||||
mk_c(c)->save_ast_trail(e);
|
||||
RETURN_Z3(of_expr(e));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
// get upper or current approximation
|
||||
Z3_ast Z3_API Z3_optimize_get_upper(Z3_context c, Z3_optimize o, unsigned idx) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_optimize_get_upper(c, o, idx);
|
||||
RESET_ERROR_CODE();
|
||||
expr_ref e = to_optimize_ptr(o)->get_upper(idx);
|
||||
mk_c(c)->save_ast_trail(e);
|
||||
RETURN_Z3(of_expr(e));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_string Z3_API Z3_optimize_to_string(Z3_context c, Z3_optimize o) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_optimize_to_string(c, o);
|
||||
RESET_ERROR_CODE();
|
||||
return mk_c(c)->mk_external_string(to_optimize_ptr(o)->to_string());
|
||||
Z3_CATCH_RETURN("");
|
||||
}
|
||||
|
||||
Z3_string Z3_API Z3_optimize_get_help(Z3_context c, Z3_optimize d) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_optimize_get_help(c, d);
|
||||
RESET_ERROR_CODE();
|
||||
std::ostringstream buffer;
|
||||
param_descrs descrs;
|
||||
to_optimize_ptr(d)->collect_param_descrs(descrs);
|
||||
descrs.display(buffer);
|
||||
return mk_c(c)->mk_external_string(buffer.str());
|
||||
Z3_CATCH_RETURN("");
|
||||
}
|
||||
|
||||
Z3_stats Z3_API Z3_optimize_get_statistics(Z3_context c,Z3_optimize d) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_optimize_get_statistics(c, d);
|
||||
RESET_ERROR_CODE();
|
||||
Z3_stats_ref * st = alloc(Z3_stats_ref);
|
||||
to_optimize_ptr(d)->collect_statistics(st->m_stats);
|
||||
mk_c(c)->save_object(st);
|
||||
Z3_stats r = of_stats(st);
|
||||
RETURN_Z3(r);
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
61
src/api/api_pb.cpp
Normal file
61
src/api/api_pb.cpp
Normal file
|
@ -0,0 +1,61 @@
|
|||
/*++
|
||||
Copyright (c) 2013 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
api_pb.cpp
|
||||
|
||||
Abstract:
|
||||
API for pb theory
|
||||
|
||||
Author:
|
||||
|
||||
Nikolaj Bjorner (nbjorner) 2013-11-13.
|
||||
|
||||
Revision History:
|
||||
|
||||
--*/
|
||||
#include<iostream>
|
||||
#include"z3.h"
|
||||
#include"api_log_macros.h"
|
||||
#include"api_context.h"
|
||||
#include"api_util.h"
|
||||
#include"pb_decl_plugin.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
Z3_ast Z3_API Z3_mk_atmost(Z3_context c, unsigned num_args,
|
||||
Z3_ast const args[], unsigned k) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_atmost(c, num_args, args, k);
|
||||
RESET_ERROR_CODE();
|
||||
parameter param(k);
|
||||
pb_util util(mk_c(c)->m());
|
||||
ast* a = util.mk_at_most_k(num_args, to_exprs(args), k);
|
||||
mk_c(c)->save_ast_trail(a);
|
||||
check_sorts(c, a);
|
||||
RETURN_Z3(of_ast(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
Z3_ast Z3_API Z3_mk_pble(Z3_context c, unsigned num_args,
|
||||
Z3_ast const args[], int _coeffs[],
|
||||
int k) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_pble(c, num_args, args, _coeffs, k);
|
||||
RESET_ERROR_CODE();
|
||||
pb_util util(mk_c(c)->m());
|
||||
vector<rational> coeffs;
|
||||
for (unsigned i = 0; i < num_args; ++i) {
|
||||
coeffs.push_back(rational(_coeffs[i]));
|
||||
}
|
||||
ast* a = util.mk_le(num_args, coeffs.c_ptr(), to_exprs(args), rational(k));
|
||||
mk_c(c)->save_ast_trail(a);
|
||||
check_sorts(c, a);
|
||||
RETURN_Z3(of_ast(a));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
};
|
|
@ -16,8 +16,8 @@ Author:
|
|||
Notes:
|
||||
|
||||
--*/
|
||||
#ifndef _API_POLYNOMIAL_H_
|
||||
#define _API_POLYNOMIAL_H_
|
||||
#ifndef API_POLYNOMIAL_H_
|
||||
#define API_POLYNOMIAL_H_
|
||||
|
||||
#include"polynomial.h"
|
||||
|
||||
|
|
|
@ -254,6 +254,7 @@ extern "C" {
|
|||
}
|
||||
expr * const * _assumptions = to_exprs(assumptions);
|
||||
unsigned timeout = to_solver(s)->m_params.get_uint("timeout", mk_c(c)->get_timeout());
|
||||
unsigned rlimit = to_solver(s)->m_params.get_uint("rlimit", mk_c(c)->get_rlimit());
|
||||
bool use_ctrl_c = to_solver(s)->m_params.get_bool("ctrl_c", false);
|
||||
cancel_eh<solver> eh(*to_solver_ref(s));
|
||||
api::context::set_interruptable si(*(mk_c(c)), eh);
|
||||
|
@ -261,6 +262,7 @@ extern "C" {
|
|||
{
|
||||
scoped_ctrl_c ctrlc(eh, false, use_ctrl_c);
|
||||
scoped_timer timer(timeout, &eh);
|
||||
scoped_rlimit _rlimit(mk_c(c)->m().limit(), rlimit);
|
||||
try {
|
||||
result = to_solver_ref(s)->check_sat(num_assumptions, _assumptions);
|
||||
}
|
||||
|
@ -355,6 +357,8 @@ extern "C" {
|
|||
init_solver(c, s);
|
||||
Z3_stats_ref * st = alloc(Z3_stats_ref);
|
||||
to_solver_ref(s)->collect_statistics(st->m_stats);
|
||||
get_memory_statistics(st->m_stats);
|
||||
get_rlimit_statistics(mk_c(c)->m().limit(), st->m_stats);
|
||||
mk_c(c)->save_object(st);
|
||||
Z3_stats r = of_stats(st);
|
||||
RETURN_Z3(r);
|
||||
|
|
|
@ -15,8 +15,8 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef _API_SOLVER_H_
|
||||
#define _API_SOLVER_H_
|
||||
#ifndef API_SOLVER_H_
|
||||
#define API_SOLVER_H_
|
||||
|
||||
#include"api_util.h"
|
||||
#include"solver.h"
|
||||
|
|
|
@ -15,8 +15,8 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef _API_STATS_H_
|
||||
#define _API_STATS_H_
|
||||
#ifndef API_STATS_H_
|
||||
#define API_STATS_H_
|
||||
|
||||
#include"api_util.h"
|
||||
#include"statistics.h"
|
||||
|
|
|
@ -15,8 +15,8 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef _API_TACTIC_H_
|
||||
#define _API_TACTIC_H_
|
||||
#ifndef API_TACTIC_H_
|
||||
#define API_TACTIC_H_
|
||||
|
||||
#include"api_goal.h"
|
||||
#include"tactical.h"
|
||||
|
|
|
@ -15,8 +15,8 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef _API_UTIL_H_
|
||||
#define _API_UTIL_H_
|
||||
#ifndef API_UTIL_H_
|
||||
#define API_UTIL_H_
|
||||
|
||||
#include"params.h"
|
||||
#include"lbool.h"
|
||||
|
|
|
@ -18,8 +18,8 @@ Author:
|
|||
Notes:
|
||||
|
||||
--*/
|
||||
#ifndef __Z3PP_H_
|
||||
#define __Z3PP_H_
|
||||
#ifndef Z3PP_H_
|
||||
#define Z3PP_H_
|
||||
|
||||
#include<cassert>
|
||||
#include<iostream>
|
||||
|
@ -203,7 +203,12 @@ namespace z3 {
|
|||
and in \c ts the predicates for testing if terms of the enumeration sort correspond to an enumeration.
|
||||
*/
|
||||
sort enumeration_sort(char const * name, unsigned n, char const * const * enum_names, func_decl_vector & cs, func_decl_vector & ts);
|
||||
|
||||
/**
|
||||
\brief create an uninterpreted sort with the name given by the string or symbol.
|
||||
*/
|
||||
sort uninterpreted_sort(char const* name);
|
||||
sort uninterpreted_sort(symbol const& name);
|
||||
|
||||
func_decl function(symbol const & name, unsigned arity, sort const * domain, sort const & range);
|
||||
func_decl function(char const * name, unsigned arity, sort const * domain, sort const & range);
|
||||
func_decl function(symbol const& name, sort_vector const& domain, sort const& range);
|
||||
|
@ -655,6 +660,7 @@ namespace z3 {
|
|||
friend expr ite(expr const & c, expr const & t, expr const & e);
|
||||
|
||||
friend expr distinct(expr_vector const& args);
|
||||
friend expr concat(expr const& a, expr const& b);
|
||||
|
||||
friend expr operator==(expr const & a, expr const & b) {
|
||||
check_context(a, b);
|
||||
|
@ -677,7 +683,7 @@ namespace z3 {
|
|||
|
||||
friend expr operator+(expr const & a, expr const & b) {
|
||||
check_context(a, b);
|
||||
Z3_ast r;
|
||||
Z3_ast r = 0;
|
||||
if (a.is_arith() && b.is_arith()) {
|
||||
Z3_ast args[2] = { a, b };
|
||||
r = Z3_mk_add(a.ctx(), 2, args);
|
||||
|
@ -697,7 +703,7 @@ namespace z3 {
|
|||
|
||||
friend expr operator*(expr const & a, expr const & b) {
|
||||
check_context(a, b);
|
||||
Z3_ast r;
|
||||
Z3_ast r = 0;
|
||||
if (a.is_arith() && b.is_arith()) {
|
||||
Z3_ast args[2] = { a, b };
|
||||
r = Z3_mk_mul(a.ctx(), 2, args);
|
||||
|
@ -724,7 +730,7 @@ namespace z3 {
|
|||
|
||||
friend expr operator/(expr const & a, expr const & b) {
|
||||
check_context(a, b);
|
||||
Z3_ast r;
|
||||
Z3_ast r = 0;
|
||||
if (a.is_arith() && b.is_arith()) {
|
||||
r = Z3_mk_div(a.ctx(), a, b);
|
||||
}
|
||||
|
@ -742,7 +748,7 @@ 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_ast r = 0;
|
||||
if (a.is_arith()) {
|
||||
r = Z3_mk_unary_minus(a.ctx(), a);
|
||||
}
|
||||
|
@ -759,7 +765,7 @@ namespace z3 {
|
|||
|
||||
friend expr operator-(expr const & a, expr const & b) {
|
||||
check_context(a, b);
|
||||
Z3_ast r;
|
||||
Z3_ast r = 0;
|
||||
if (a.is_arith() && b.is_arith()) {
|
||||
Z3_ast args[2] = { a, b };
|
||||
r = Z3_mk_sub(a.ctx(), 2, args);
|
||||
|
@ -779,7 +785,7 @@ namespace z3 {
|
|||
|
||||
friend expr operator<=(expr const & a, expr const & b) {
|
||||
check_context(a, b);
|
||||
Z3_ast r;
|
||||
Z3_ast r = 0;
|
||||
if (a.is_arith() && b.is_arith()) {
|
||||
r = Z3_mk_le(a.ctx(), a, b);
|
||||
}
|
||||
|
@ -798,7 +804,7 @@ namespace z3 {
|
|||
|
||||
friend expr operator>=(expr const & a, expr const & b) {
|
||||
check_context(a, b);
|
||||
Z3_ast r;
|
||||
Z3_ast r = 0;
|
||||
if (a.is_arith() && b.is_arith()) {
|
||||
r = Z3_mk_ge(a.ctx(), a, b);
|
||||
}
|
||||
|
@ -817,7 +823,7 @@ namespace z3 {
|
|||
|
||||
friend expr operator<(expr const & a, expr const & b) {
|
||||
check_context(a, b);
|
||||
Z3_ast r;
|
||||
Z3_ast r = 0;
|
||||
if (a.is_arith() && b.is_arith()) {
|
||||
r = Z3_mk_lt(a.ctx(), a, b);
|
||||
}
|
||||
|
@ -836,7 +842,7 @@ namespace z3 {
|
|||
|
||||
friend expr operator>(expr const & a, expr const & b) {
|
||||
check_context(a, b);
|
||||
Z3_ast r;
|
||||
Z3_ast r = 0;
|
||||
if (a.is_arith() && b.is_arith()) {
|
||||
r = Z3_mk_gt(a.ctx(), a, b);
|
||||
}
|
||||
|
@ -1108,6 +1114,13 @@ namespace z3 {
|
|||
ctx.check_error();
|
||||
return expr(ctx, r);
|
||||
}
|
||||
|
||||
inline expr concat(expr const& a, expr const& b) {
|
||||
check_context(a, b);
|
||||
Z3_ast r = Z3_mk_concat(a.ctx(), a, b);
|
||||
a.ctx().check_error();
|
||||
return expr(a.ctx(), r);
|
||||
}
|
||||
|
||||
class func_entry : public object {
|
||||
Z3_func_entry m_entry;
|
||||
|
@ -1176,7 +1189,7 @@ namespace z3 {
|
|||
|
||||
expr eval(expr const & n, bool model_completion=false) const {
|
||||
check_context(*this, n);
|
||||
Z3_ast r;
|
||||
Z3_ast r = 0;
|
||||
Z3_bool status = Z3_model_eval(ctx(), m_model, n, model_completion, &r);
|
||||
check_error();
|
||||
if (status == Z3_FALSE)
|
||||
|
@ -1536,6 +1549,62 @@ namespace z3 {
|
|||
}
|
||||
};
|
||||
|
||||
class optimize : public object {
|
||||
Z3_optimize m_opt;
|
||||
public:
|
||||
class handle {
|
||||
unsigned m_h;
|
||||
public:
|
||||
handle(unsigned h): m_h(h) {}
|
||||
unsigned h() const { return m_h; }
|
||||
};
|
||||
optimize(context& c):object(c) { m_opt = Z3_mk_optimize(c); Z3_optimize_inc_ref(c, m_opt); }
|
||||
~optimize() { Z3_optimize_dec_ref(ctx(), m_opt); }
|
||||
operator Z3_optimize() const { return m_opt; }
|
||||
void add(expr const& e) {
|
||||
assert(e.is_bool());
|
||||
Z3_optimize_assert(ctx(), m_opt, e);
|
||||
}
|
||||
handle add(expr const& e, unsigned weight) {
|
||||
assert(e.is_bool());
|
||||
std::stringstream strm;
|
||||
strm << weight;
|
||||
return handle(Z3_optimize_assert_soft(ctx(), m_opt, e, strm.str().c_str(), 0));
|
||||
}
|
||||
handle add(expr const& e, char const* weight) {
|
||||
assert(e.is_bool());
|
||||
return handle(Z3_optimize_assert_soft(ctx(), m_opt, e, weight, 0));
|
||||
}
|
||||
handle maximize(expr const& e) {
|
||||
return handle(Z3_optimize_maximize(ctx(), m_opt, e));
|
||||
}
|
||||
handle minimize(expr const& e) {
|
||||
return handle(Z3_optimize_minimize(ctx(), m_opt, e));
|
||||
}
|
||||
void push() {
|
||||
Z3_optimize_push(ctx(), m_opt);
|
||||
}
|
||||
void pop() {
|
||||
Z3_optimize_pop(ctx(), m_opt);
|
||||
}
|
||||
check_result check() { Z3_lbool r = Z3_optimize_check(ctx(), m_opt); check_error(); return to_check_result(r); }
|
||||
model get_model() const { Z3_model m = Z3_optimize_get_model(ctx(), m_opt); check_error(); return model(ctx(), m); }
|
||||
void set(params const & p) { Z3_optimize_set_params(ctx(), m_opt, p); check_error(); }
|
||||
expr lower(handle const& h) {
|
||||
Z3_ast r = Z3_optimize_get_lower(ctx(), m_opt, h.h());
|
||||
check_error();
|
||||
return expr(ctx(), r);
|
||||
}
|
||||
expr upper(handle const& h) {
|
||||
Z3_ast r = Z3_optimize_get_upper(ctx(), m_opt, h.h());
|
||||
check_error();
|
||||
return expr(ctx(), r);
|
||||
}
|
||||
stats statistics() const { Z3_stats r = Z3_optimize_get_statistics(ctx(), m_opt); check_error(); return stats(ctx(), r); }
|
||||
friend std::ostream & operator<<(std::ostream & out, optimize const & s) { out << Z3_optimize_to_string(s.ctx(), s.m_opt); return out; }
|
||||
std::string help() const { char const * r = Z3_optimize_get_help(ctx(), m_opt); check_error(); return r; }
|
||||
};
|
||||
|
||||
inline tactic fail_if(probe const & p) {
|
||||
Z3_tactic r = Z3_tactic_fail_if(p.ctx(), p);
|
||||
p.check_error();
|
||||
|
@ -1573,6 +1642,13 @@ namespace z3 {
|
|||
for (unsigned i = 0; i < n; i++) { cs.push_back(func_decl(*this, _cs[i])); ts.push_back(func_decl(*this, _ts[i])); }
|
||||
return s;
|
||||
}
|
||||
inline sort context::uninterpreted_sort(char const* name) {
|
||||
Z3_symbol _name = Z3_mk_string_symbol(*this, name);
|
||||
return to_sort(*this, Z3_mk_uninterpreted_sort(*this, _name));
|
||||
}
|
||||
inline sort context::uninterpreted_sort(symbol const& name) {
|
||||
return to_sort(*this, Z3_mk_uninterpreted_sort(*this, name));
|
||||
}
|
||||
|
||||
inline func_decl context::function(symbol const & name, unsigned arity, sort const * domain, sort const & range) {
|
||||
array<Z3_sort> args(arity);
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
|
||||
/*++
|
||||
Copyright (c) 2015 Microsoft Corporation
|
||||
|
||||
--*/
|
||||
|
||||
#ifdef _WINDOWS
|
||||
|
||||
#include<windows.h>
|
||||
|
|
|
@ -98,11 +98,12 @@ namespace Microsoft.Z3
|
|||
/// <summary>
|
||||
/// The keys stored in the map.
|
||||
/// </summary>
|
||||
public ASTVector Keys
|
||||
public AST[] Keys
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ASTVector(Context, Native.Z3_ast_map_keys(Context.nCtx, NativeObject));
|
||||
ASTVector res = new ASTVector(Context, Native.Z3_ast_map_keys(Context.nCtx, NativeObject));
|
||||
return res.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -99,6 +99,138 @@ namespace Microsoft.Z3
|
|||
return Native.Z3_ast_vector_to_string(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Translates an AST vector into an AST[]
|
||||
/// </summary>
|
||||
public AST[] ToArray()
|
||||
{
|
||||
uint n = Size;
|
||||
AST[] res = new AST[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = AST.Create(this.Context, this[i].NativeObject);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Translates an ASTVector into an Expr[]
|
||||
/// </summary>
|
||||
public Expr[] ToExprArray()
|
||||
{
|
||||
uint n = Size;
|
||||
Expr[] res = new Expr[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = Expr.Create(this.Context, this[i].NativeObject);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Translates an ASTVector into a BoolExpr[]
|
||||
/// </summary>
|
||||
public BoolExpr[] ToBoolExprArray()
|
||||
{
|
||||
uint n = Size;
|
||||
BoolExpr[] res = new BoolExpr[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = (BoolExpr) Expr.Create(this.Context, this[i].NativeObject);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Translates an ASTVector into a BitVecExpr[]
|
||||
/// </summary>
|
||||
public BitVecExpr[] ToBitVecExprArray()
|
||||
{
|
||||
uint n = Size;
|
||||
BitVecExpr[] res = new BitVecExpr[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = (BitVecExpr)Expr.Create(this.Context, this[i].NativeObject);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Translates an ASTVector into a ArithExpr[]
|
||||
/// </summary>
|
||||
public ArithExpr[] ToArithExprArray()
|
||||
{
|
||||
uint n = Size;
|
||||
ArithExpr[] res = new ArithExpr[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = (ArithExpr)Expr.Create(this.Context, this[i].NativeObject);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Translates an ASTVector into a ArrayExpr[]
|
||||
/// </summary>
|
||||
public ArrayExpr[] ToArrayExprArray()
|
||||
{
|
||||
uint n = Size;
|
||||
ArrayExpr[] res = new ArrayExpr[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = (ArrayExpr)Expr.Create(this.Context, this[i].NativeObject);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Translates an ASTVector into a DatatypeExpr[]
|
||||
/// </summary>
|
||||
public DatatypeExpr[] ToDatatypeExprArray()
|
||||
{
|
||||
uint n = Size;
|
||||
DatatypeExpr[] res = new DatatypeExpr[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = (DatatypeExpr)Expr.Create(this.Context, this[i].NativeObject);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Translates an ASTVector into a FPExpr[]
|
||||
/// </summary>
|
||||
public FPExpr[] ToFPExprArray()
|
||||
{
|
||||
uint n = Size;
|
||||
FPExpr[] res = new FPExpr[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = (FPExpr)Expr.Create(this.Context, this[i].NativeObject);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Translates an ASTVector into a FPRMExpr[]
|
||||
/// </summary>
|
||||
public FPRMExpr[] ToFPRMExprArray()
|
||||
{
|
||||
uint n = Size;
|
||||
FPRMExpr[] res = new FPRMExpr[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = (FPRMExpr)Expr.Create(this.Context, this[i].NativeObject);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Translates an ASTVector into a IntExpr[]
|
||||
/// </summary>
|
||||
public IntExpr[] ToIntExprArray()
|
||||
{
|
||||
uint n = Size;
|
||||
IntExpr[] res = new IntExpr[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = (IntExpr)Expr.Create(this.Context, this[i].NativeObject);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Translates an ASTVector into a RealExpr[]
|
||||
/// </summary>
|
||||
public RealExpr[] ToRealExprArray()
|
||||
{
|
||||
uint n = Size;
|
||||
RealExpr[] res = new RealExpr[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = (RealExpr)Expr.Create(this.Context, this[i].NativeObject);
|
||||
return res;
|
||||
}
|
||||
|
||||
#region Internal
|
||||
internal ASTVector(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
|
||||
internal ASTVector(Context ctx) : base(ctx, Native.Z3_mk_ast_vector(ctx.nCtx)) { Contract.Requires(ctx != null); }
|
||||
|
|
|
@ -449,6 +449,19 @@ namespace Microsoft.Z3
|
|||
return MkDatatypeSorts(MkSymbols(names), c);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update a datatype field at expression t with value v.
|
||||
/// The function performs a record update at t. The field
|
||||
/// that is passed in as argument is updated with value v,
|
||||
/// the remainig fields of t are unchanged.
|
||||
/// </summary>
|
||||
public Expr MkUpdateField(FuncDecl field, Expr t, Expr v)
|
||||
{
|
||||
return Expr.Create(this, Native.Z3_datatype_update_field(
|
||||
nCtx, field.NativeObject,
|
||||
t.NativeObject, v.NativeObject));
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
|
@ -2121,31 +2134,31 @@ namespace Microsoft.Z3
|
|||
/// <summary>
|
||||
/// Create an empty set.
|
||||
/// </summary>
|
||||
public Expr MkEmptySet(Sort domain)
|
||||
public ArrayExpr MkEmptySet(Sort domain)
|
||||
{
|
||||
Contract.Requires(domain != null);
|
||||
Contract.Ensures(Contract.Result<Expr>() != null);
|
||||
|
||||
CheckContextMatch(domain);
|
||||
return Expr.Create(this, Native.Z3_mk_empty_set(nCtx, domain.NativeObject));
|
||||
return (ArrayExpr)Expr.Create(this, Native.Z3_mk_empty_set(nCtx, domain.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create the full set.
|
||||
/// </summary>
|
||||
public Expr MkFullSet(Sort domain)
|
||||
public ArrayExpr MkFullSet(Sort domain)
|
||||
{
|
||||
Contract.Requires(domain != null);
|
||||
Contract.Ensures(Contract.Result<Expr>() != null);
|
||||
|
||||
CheckContextMatch(domain);
|
||||
return Expr.Create(this, Native.Z3_mk_full_set(nCtx, domain.NativeObject));
|
||||
return (ArrayExpr)Expr.Create(this, Native.Z3_mk_full_set(nCtx, domain.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add an element to the set.
|
||||
/// </summary>
|
||||
public Expr MkSetAdd(Expr set, Expr element)
|
||||
public ArrayExpr MkSetAdd(ArrayExpr set, Expr element)
|
||||
{
|
||||
Contract.Requires(set != null);
|
||||
Contract.Requires(element != null);
|
||||
|
@ -2153,14 +2166,14 @@ namespace Microsoft.Z3
|
|||
|
||||
CheckContextMatch(set);
|
||||
CheckContextMatch(element);
|
||||
return Expr.Create(this, Native.Z3_mk_set_add(nCtx, set.NativeObject, element.NativeObject));
|
||||
return (ArrayExpr)Expr.Create(this, Native.Z3_mk_set_add(nCtx, set.NativeObject, element.NativeObject));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Remove an element from a set.
|
||||
/// </summary>
|
||||
public Expr MkSetDel(Expr set, Expr element)
|
||||
public ArrayExpr MkSetDel(ArrayExpr set, Expr element)
|
||||
{
|
||||
Contract.Requires(set != null);
|
||||
Contract.Requires(element != null);
|
||||
|
@ -2168,38 +2181,38 @@ namespace Microsoft.Z3
|
|||
|
||||
CheckContextMatch(set);
|
||||
CheckContextMatch(element);
|
||||
return Expr.Create(this, Native.Z3_mk_set_del(nCtx, set.NativeObject, element.NativeObject));
|
||||
return (ArrayExpr)Expr.Create(this, Native.Z3_mk_set_del(nCtx, set.NativeObject, element.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Take the union of a list of sets.
|
||||
/// </summary>
|
||||
public Expr MkSetUnion(params Expr[] args)
|
||||
public ArrayExpr MkSetUnion(params ArrayExpr[] args)
|
||||
{
|
||||
Contract.Requires(args != null);
|
||||
Contract.Requires(Contract.ForAll(args, a => a != null));
|
||||
|
||||
CheckContextMatch(args);
|
||||
return Expr.Create(this, Native.Z3_mk_set_union(nCtx, (uint)args.Length, AST.ArrayToNative(args)));
|
||||
return (ArrayExpr)Expr.Create(this, Native.Z3_mk_set_union(nCtx, (uint)args.Length, AST.ArrayToNative(args)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Take the intersection of a list of sets.
|
||||
/// </summary>
|
||||
public Expr MkSetIntersection(params Expr[] args)
|
||||
public ArrayExpr MkSetIntersection(params ArrayExpr[] args)
|
||||
{
|
||||
Contract.Requires(args != null);
|
||||
Contract.Requires(Contract.ForAll(args, a => a != null));
|
||||
Contract.Ensures(Contract.Result<Expr>() != null);
|
||||
|
||||
CheckContextMatch(args);
|
||||
return Expr.Create(this, Native.Z3_mk_set_intersect(nCtx, (uint)args.Length, AST.ArrayToNative(args)));
|
||||
return (ArrayExpr)Expr.Create(this, Native.Z3_mk_set_intersect(nCtx, (uint)args.Length, AST.ArrayToNative(args)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Take the difference between two sets.
|
||||
/// </summary>
|
||||
public Expr MkSetDifference(Expr arg1, Expr arg2)
|
||||
public ArrayExpr MkSetDifference(ArrayExpr arg1, ArrayExpr arg2)
|
||||
{
|
||||
Contract.Requires(arg1 != null);
|
||||
Contract.Requires(arg2 != null);
|
||||
|
@ -2207,25 +2220,25 @@ namespace Microsoft.Z3
|
|||
|
||||
CheckContextMatch(arg1);
|
||||
CheckContextMatch(arg2);
|
||||
return Expr.Create(this, Native.Z3_mk_set_difference(nCtx, arg1.NativeObject, arg2.NativeObject));
|
||||
return (ArrayExpr)Expr.Create(this, Native.Z3_mk_set_difference(nCtx, arg1.NativeObject, arg2.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Take the complement of a set.
|
||||
/// </summary>
|
||||
public Expr MkSetComplement(Expr arg)
|
||||
public ArrayExpr MkSetComplement(ArrayExpr arg)
|
||||
{
|
||||
Contract.Requires(arg != null);
|
||||
Contract.Ensures(Contract.Result<Expr>() != null);
|
||||
|
||||
CheckContextMatch(arg);
|
||||
return Expr.Create(this, Native.Z3_mk_set_complement(nCtx, arg.NativeObject));
|
||||
return (ArrayExpr)Expr.Create(this, Native.Z3_mk_set_complement(nCtx, arg.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check for set membership.
|
||||
/// </summary>
|
||||
public Expr MkSetMembership(Expr elem, Expr set)
|
||||
public BoolExpr MkSetMembership(Expr elem, ArrayExpr set)
|
||||
{
|
||||
Contract.Requires(elem != null);
|
||||
Contract.Requires(set != null);
|
||||
|
@ -2233,13 +2246,13 @@ namespace Microsoft.Z3
|
|||
|
||||
CheckContextMatch(elem);
|
||||
CheckContextMatch(set);
|
||||
return Expr.Create(this, Native.Z3_mk_set_member(nCtx, elem.NativeObject, set.NativeObject));
|
||||
return (BoolExpr) Expr.Create(this, Native.Z3_mk_set_member(nCtx, elem.NativeObject, set.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check for subsetness of sets.
|
||||
/// </summary>
|
||||
public Expr MkSetSubset(Expr arg1, Expr arg2)
|
||||
public BoolExpr MkSetSubset(ArrayExpr arg1, ArrayExpr arg2)
|
||||
{
|
||||
Contract.Requires(arg1 != null);
|
||||
Contract.Requires(arg2 != null);
|
||||
|
@ -2247,7 +2260,37 @@ namespace Microsoft.Z3
|
|||
|
||||
CheckContextMatch(arg1);
|
||||
CheckContextMatch(arg2);
|
||||
return Expr.Create(this, Native.Z3_mk_set_subset(nCtx, arg1.NativeObject, arg2.NativeObject));
|
||||
return (BoolExpr) Expr.Create(this, Native.Z3_mk_set_subset(nCtx, arg1.NativeObject, arg2.NativeObject));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Pseudo-Boolean constraints
|
||||
|
||||
/// <summary>
|
||||
/// Create an at-most-k constraint.
|
||||
/// </summary>
|
||||
public BoolExpr MkAtMost(BoolExpr[] args, uint k)
|
||||
{
|
||||
Contract.Requires(args != null);
|
||||
Contract.Requires(Contract.Result<BoolExpr[]>() != null);
|
||||
CheckContextMatch(args);
|
||||
return new BoolExpr(this, Native.Z3_mk_atmost(nCtx, (uint) args.Length,
|
||||
AST.ArrayToNative(args), k));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a pseudo-Boolean less-or-equal constraint.
|
||||
/// </summary>
|
||||
public BoolExpr MkPBLe(int[] coeffs, BoolExpr[] args, int k)
|
||||
{
|
||||
Contract.Requires(args != null);
|
||||
Contract.Requires(coeffs != null);
|
||||
Contract.Requires(args.Length == coeffs.Length);
|
||||
Contract.Requires(Contract.Result<BoolExpr[]>() != null);
|
||||
CheckContextMatch(args);
|
||||
return new BoolExpr(this, Native.Z3_mk_pble(nCtx, (uint) args.Length,
|
||||
AST.ArrayToNative(args),
|
||||
coeffs, k));
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -3438,6 +3481,18 @@ namespace Microsoft.Z3
|
|||
}
|
||||
#endregion
|
||||
|
||||
#region Optimization
|
||||
/// <summary>
|
||||
/// Create an Optimization context.
|
||||
/// </summary>
|
||||
public Optimize MkOptimize()
|
||||
{
|
||||
Contract.Ensures(Contract.Result<Optimize>() != null);
|
||||
|
||||
return new Optimize(this);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Floating-Point Arithmetic
|
||||
|
||||
#region Rounding Modes
|
||||
|
@ -4383,6 +4438,7 @@ namespace Microsoft.Z3
|
|||
Contract.Invariant(m_Statistics_DRQ != null);
|
||||
Contract.Invariant(m_Tactic_DRQ != null);
|
||||
Contract.Invariant(m_Fixedpoint_DRQ != null);
|
||||
Contract.Invariant(m_Optimize_DRQ != null);
|
||||
}
|
||||
|
||||
readonly private AST.DecRefQueue m_AST_DRQ = new AST.DecRefQueue();
|
||||
|
@ -4400,6 +4456,7 @@ namespace Microsoft.Z3
|
|||
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);
|
||||
readonly private Optimize.DecRefQueue m_Optimize_DRQ = new Optimize.DecRefQueue(10);
|
||||
|
||||
/// <summary>
|
||||
/// AST DRQ
|
||||
|
@ -4476,6 +4533,11 @@ namespace Microsoft.Z3
|
|||
/// </summary>
|
||||
public IDecRefQueue Fixedpoint_DRQ { get { Contract.Ensures(Contract.Result<Fixedpoint.DecRefQueue>() != null); return m_Fixedpoint_DRQ; } }
|
||||
|
||||
/// <summary>
|
||||
/// Optimize DRQ
|
||||
/// </summary>
|
||||
public IDecRefQueue Optimize_DRQ { get { Contract.Ensures(Contract.Result<Optimize.DecRefQueue>() != null); return m_Fixedpoint_DRQ; } }
|
||||
|
||||
|
||||
internal long refCount = 0;
|
||||
|
||||
|
@ -4518,6 +4580,7 @@ namespace Microsoft.Z3
|
|||
Statistics_DRQ.Clear(this);
|
||||
Tactic_DRQ.Clear(this);
|
||||
Fixedpoint_DRQ.Clear(this);
|
||||
Optimize_DRQ.Clear(this);
|
||||
|
||||
m_boolSort = null;
|
||||
m_intSort = null;
|
||||
|
|
111
src/api/dotnet/Deprecated.cs
Normal file
111
src/api/dotnet/Deprecated.cs
Normal file
|
@ -0,0 +1,111 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Deprecated.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Expose deprecated features for use from the managed API
|
||||
those who use them for experiments.
|
||||
|
||||
Author:
|
||||
|
||||
Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// The main interaction with Z3 happens via the Context.
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class Deprecated
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Creates a backtracking point.
|
||||
/// </summary>
|
||||
/// <seealso cref="Pop"/>
|
||||
public static void Push(Context ctx) {
|
||||
Native.Z3_push(ctx.nCtx);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Backtracks <paramref name="n"/> backtracking points.
|
||||
/// </summary>
|
||||
/// <remarks>Note that an exception is thrown if <paramref name="n"/> is not smaller than <c>NumScopes</c></remarks>
|
||||
/// <seealso cref="Push"/>
|
||||
public static void Pop(Context ctx, uint n = 1) {
|
||||
Native.Z3_pop(ctx.nCtx, n);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Assert a constraint (or multiple) into the solver.
|
||||
/// </summary>
|
||||
public static void Assert(Context ctx, params BoolExpr[] constraints)
|
||||
{
|
||||
Contract.Requires(constraints != null);
|
||||
Contract.Requires(Contract.ForAll(constraints, c => c != null));
|
||||
|
||||
ctx.CheckContextMatch(constraints);
|
||||
foreach (BoolExpr a in constraints)
|
||||
{
|
||||
Native.Z3_assert_cnstr(ctx.nCtx, a.NativeObject);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Checks whether the assertions in the context are consistent or not.
|
||||
/// </summary>
|
||||
public static Status Check(Context ctx, List<BoolExpr> core, ref Model model, ref Expr proof, params Expr[] assumptions)
|
||||
{
|
||||
Z3_lbool r;
|
||||
model = null;
|
||||
proof = null;
|
||||
if (assumptions == null || assumptions.Length == 0)
|
||||
r = (Z3_lbool)Native.Z3_check(ctx.nCtx);
|
||||
else {
|
||||
IntPtr mdl = IntPtr.Zero, prf = IntPtr.Zero;
|
||||
uint core_size = 0;
|
||||
IntPtr[] native_core = new IntPtr[assumptions.Length];
|
||||
r = (Z3_lbool)Native.Z3_check_assumptions(ctx.nCtx,
|
||||
(uint)assumptions.Length, AST.ArrayToNative(assumptions),
|
||||
ref mdl, ref prf, ref core_size, native_core);
|
||||
|
||||
for (uint i = 0; i < core_size; i++)
|
||||
core.Add((BoolExpr)Expr.Create(ctx, native_core[i]));
|
||||
if (mdl != IntPtr.Zero) {
|
||||
model = new Model(ctx, mdl);
|
||||
}
|
||||
if (prf != IntPtr.Zero) {
|
||||
proof = Expr.Create(ctx, prf);
|
||||
}
|
||||
|
||||
}
|
||||
switch (r)
|
||||
{
|
||||
case Z3_lbool.Z3_L_TRUE: return Status.SATISFIABLE;
|
||||
case Z3_lbool.Z3_L_FALSE: return Status.UNSATISFIABLE;
|
||||
default: return Status.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves an assignment to atomic propositions for a satisfiable context.
|
||||
/// </summary>
|
||||
public static BoolExpr GetAssignment(Context ctx)
|
||||
{
|
||||
IntPtr x = Native.Z3_get_context_assignment(ctx.nCtx);
|
||||
return (BoolExpr)Expr.Create(ctx, x);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -59,6 +59,25 @@ namespace Microsoft.Z3
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The significand value of a floating-point numeral as a UInt64
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This function extracts the significand bits, without the
|
||||
/// hidden bit or normalization. Throws an exception if the
|
||||
/// significand does not fit into a UInt64.
|
||||
/// </remarks>
|
||||
public UInt64 SignificandUInt64
|
||||
{
|
||||
get
|
||||
{
|
||||
UInt64 result = 0;
|
||||
if (Native.Z3_fpa_get_numeral_significand_uint64(Context.nCtx, NativeObject, ref result) == 0)
|
||||
throw new Z3Exception("Significand is not a 64 bit unsigned integer");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the exponent value of a floating-point numeral as a string
|
||||
/// </summary>
|
||||
|
|
|
@ -269,14 +269,6 @@ namespace Microsoft.Z3
|
|||
AST.ArrayLength(queries), AST.ArrayToNative(queries));
|
||||
}
|
||||
|
||||
BoolExpr[] ToBoolExprs(ASTVector v) {
|
||||
uint n = v.Size;
|
||||
BoolExpr[] res = new BoolExpr[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = new BoolExpr(Context, v[i].NativeObject);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve set of rules added to fixedpoint context.
|
||||
/// </summary>
|
||||
|
@ -286,7 +278,8 @@ namespace Microsoft.Z3
|
|||
{
|
||||
Contract.Ensures(Contract.Result<BoolExpr[]>() != null);
|
||||
|
||||
return ToBoolExprs(new ASTVector(Context, Native.Z3_fixedpoint_get_rules(Context.nCtx, NativeObject)));
|
||||
ASTVector av = new ASTVector(Context, Native.Z3_fixedpoint_get_rules(Context.nCtx, NativeObject));
|
||||
return av.ToBoolExprArray();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -299,7 +292,21 @@ namespace Microsoft.Z3
|
|||
{
|
||||
Contract.Ensures(Contract.Result<BoolExpr[]>() != null);
|
||||
|
||||
return ToBoolExprs(new ASTVector(Context, Native.Z3_fixedpoint_get_assertions(Context.nCtx, NativeObject)));
|
||||
ASTVector av = new ASTVector(Context, Native.Z3_fixedpoint_get_assertions(Context.nCtx, NativeObject));
|
||||
return av.ToBoolExprArray();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fixedpoint statistics.
|
||||
/// </summary>
|
||||
public Statistics Statistics
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<Statistics>() != null);
|
||||
|
||||
return new Statistics(Context, Native.Z3_fixedpoint_get_statistics(Context.nCtx, NativeObject));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -308,16 +315,19 @@ namespace Microsoft.Z3
|
|||
/// Add the rules to the current fixedpoint context.
|
||||
/// Return the set of queries in the file.
|
||||
/// </summary>
|
||||
public BoolExpr[] ParseFile(string file) {
|
||||
return ToBoolExprs(new ASTVector(Context, Native.Z3_fixedpoint_from_file(Context.nCtx, NativeObject, file)));
|
||||
public BoolExpr[] ParseFile(string file)
|
||||
{
|
||||
ASTVector av = new ASTVector(Context, Native.Z3_fixedpoint_from_file(Context.nCtx, NativeObject, file));
|
||||
return av.ToBoolExprArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Similar to ParseFile. Instead it takes as argument a string.
|
||||
/// </summary>
|
||||
|
||||
public BoolExpr[] ParseString(string s) {
|
||||
return ToBoolExprs(new ASTVector(Context, Native.Z3_fixedpoint_from_string(Context.nCtx, NativeObject, s)));
|
||||
/// </summary>
|
||||
public BoolExpr[] ParseString(string s)
|
||||
{
|
||||
ASTVector av = new ASTVector(Context, Native.Z3_fixedpoint_from_string(Context.nCtx, NativeObject, s));
|
||||
return av.ToBoolExprArray();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -208,6 +208,21 @@ namespace Microsoft.Z3
|
|||
return Native.Z3_goal_to_string(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Goal to BoolExpr conversion.
|
||||
/// </summary>
|
||||
/// <returns>A string representation of the Goal.</returns>
|
||||
public BoolExpr AsBoolExpr() {
|
||||
uint n = Size;
|
||||
if (n == 0)
|
||||
return Context.MkTrue();
|
||||
else if (n == 1)
|
||||
return Formulas[0];
|
||||
else {
|
||||
return Context.MkAnd(Formulas);
|
||||
}
|
||||
}
|
||||
|
||||
#region Internal
|
||||
internal Goal(Context ctx, IntPtr obj) : base(ctx, obj) { Contract.Requires(ctx != null); }
|
||||
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
|
||||
/*++
|
||||
Copyright (c) 2015 Microsoft Corporation
|
||||
|
||||
--*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -47,7 +53,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>
|
||||
public Expr[] GetInterpolant(Expr pf, Expr pat, Params p)
|
||||
public BoolExpr[] GetInterpolant(Expr pf, Expr pat, Params p)
|
||||
{
|
||||
Contract.Requires(pf != null);
|
||||
Contract.Requires(pat != null);
|
||||
|
@ -59,11 +65,7 @@ namespace Microsoft.Z3
|
|||
CheckContextMatch(p);
|
||||
|
||||
ASTVector seq = new ASTVector(this, Native.Z3_get_interpolant(nCtx, pf.NativeObject, pat.NativeObject, p.NativeObject));
|
||||
uint n = seq.Size;
|
||||
Expr[] res = new Expr[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = Expr.Create(this, seq[i].NativeObject);
|
||||
return res;
|
||||
return seq.ToBoolExprArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -72,7 +74,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>
|
||||
public Z3_lbool ComputeInterpolant(Expr pat, Params p, out ASTVector interp, out Model model)
|
||||
public Z3_lbool ComputeInterpolant(Expr pat, Params p, out BoolExpr[] interp, out Model model)
|
||||
{
|
||||
Contract.Requires(pat != null);
|
||||
Contract.Requires(p != null);
|
||||
|
@ -84,7 +86,7 @@ namespace Microsoft.Z3
|
|||
|
||||
IntPtr i = IntPtr.Zero, m = IntPtr.Zero;
|
||||
int r = Native.Z3_compute_interpolant(nCtx, pat.NativeObject, p.NativeObject, ref i, ref m);
|
||||
interp = new ASTVector(this, i);
|
||||
interp = new ASTVector(this, i).ToBoolExprArray();
|
||||
model = new Model(this, m);
|
||||
return (Z3_lbool)r;
|
||||
}
|
||||
|
@ -106,7 +108,7 @@ namespace Microsoft.Z3
|
|||
/// <remarks>For more information on interpolation please refer
|
||||
/// too the function Z3_check_interpolant in the C/C++ API, which is
|
||||
/// well documented.</remarks>
|
||||
public int CheckInterpolant(Expr[] cnsts, uint[] parents, Expr[] interps, out string error, Expr[] theory)
|
||||
public int CheckInterpolant(Expr[] cnsts, uint[] parents, BoolExpr[] interps, out string error, Expr[] theory)
|
||||
{
|
||||
Contract.Requires(cnsts.Length == parents.Length);
|
||||
Contract.Requires(cnsts.Length == interps.Length + 1);
|
||||
|
|
|
@ -365,6 +365,7 @@
|
|||
<Compile Include="IntSymbol.cs" />
|
||||
<Compile Include="ListSort.cs" />
|
||||
<Compile Include="Model.cs" />
|
||||
<Compile Include="Optimize.cs" />
|
||||
<Compile Include="Params.cs" />
|
||||
<Compile Include="ParamDescrs.cs" />
|
||||
<Compile Include="Pattern.cs" />
|
||||
|
|
|
@ -265,12 +265,8 @@ namespace Microsoft.Z3
|
|||
Contract.Requires(s != null);
|
||||
Contract.Ensures(Contract.Result<Expr[]>() != null);
|
||||
|
||||
ASTVector nUniv = new ASTVector(Context, Native.Z3_model_get_sort_universe(Context.nCtx, NativeObject, s.NativeObject));
|
||||
uint n = nUniv.Size;
|
||||
Expr[] res = new Expr[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = Expr.Create(Context, nUniv[i].NativeObject);
|
||||
return res;
|
||||
ASTVector av = new ASTVector(Context, Native.Z3_model_get_sort_universe(Context.nCtx, NativeObject, s.NativeObject));
|
||||
return av.ToExprArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
307
src/api/dotnet/Optimize.cs
Normal file
307
src/api/dotnet/Optimize.cs
Normal file
|
@ -0,0 +1,307 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Optimize.cs
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Managed API: Optimizes
|
||||
|
||||
Author:
|
||||
|
||||
Nikolaj Bjorner (nbjorner) 2013-12-03
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Microsoft.Z3
|
||||
{
|
||||
/// <summary>
|
||||
/// Object for managing optimizization context
|
||||
/// </summary>
|
||||
[ContractVerification(true)]
|
||||
public class Optimize : Z3Object
|
||||
{
|
||||
/// <summary>
|
||||
/// A string that describes all available optimize solver parameters.
|
||||
/// </summary>
|
||||
public string Help
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<string>() != null);
|
||||
return Native.Z3_optimize_get_help(Context.nCtx, NativeObject);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the optimize solver parameters.
|
||||
/// </summary>
|
||||
public Params Parameters
|
||||
{
|
||||
set
|
||||
{
|
||||
Contract.Requires(value != null);
|
||||
Context.CheckContextMatch(value);
|
||||
Native.Z3_optimize_set_params(Context.nCtx, NativeObject, value.NativeObject);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves parameter descriptions for Optimize solver.
|
||||
/// </summary>
|
||||
public ParamDescrs ParameterDescriptions
|
||||
{
|
||||
get { return new ParamDescrs(Context, Native.Z3_optimize_get_param_descrs(Context.nCtx, NativeObject)); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Assert a constraint (or multiple) into the optimize solver.
|
||||
/// </summary>
|
||||
public void Assert(params BoolExpr[] constraints)
|
||||
{
|
||||
Contract.Requires(constraints != null);
|
||||
Contract.Requires(Contract.ForAll(constraints, c => c != null));
|
||||
|
||||
Context.CheckContextMatch(constraints);
|
||||
foreach (BoolExpr a in constraints)
|
||||
{
|
||||
Native.Z3_optimize_assert(Context.nCtx, NativeObject, a.NativeObject);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Alias for Assert.
|
||||
/// </summary>
|
||||
public void Add(params BoolExpr[] constraints)
|
||||
{
|
||||
Assert(constraints);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle to objectives returned by objective functions.
|
||||
/// </summary>
|
||||
public class Handle
|
||||
{
|
||||
Optimize opt;
|
||||
uint handle;
|
||||
internal Handle(Optimize opt, uint h)
|
||||
{
|
||||
this.opt = opt;
|
||||
this.handle = h;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve a lower bound for the objective handle.
|
||||
/// </summary>
|
||||
public ArithExpr Lower
|
||||
{
|
||||
get { return opt.GetLower(handle); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve an upper bound for the objective handle.
|
||||
/// </summary>
|
||||
public ArithExpr Upper
|
||||
{
|
||||
get { return opt.GetUpper(handle); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the value of an objective.
|
||||
/// </summary>
|
||||
public ArithExpr Value
|
||||
{
|
||||
get { return Lower; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Assert soft constraint
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Return an objective which associates with the group of constraints.
|
||||
/// </remarks>
|
||||
public Handle AssertSoft(BoolExpr constraint, uint weight, string group)
|
||||
{
|
||||
Context.CheckContextMatch(constraint);
|
||||
Symbol s = Context.MkSymbol(group);
|
||||
return new Handle(this, Native.Z3_optimize_assert_soft(Context.nCtx, NativeObject, constraint.NativeObject, weight.ToString(), s.NativeObject));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Check satisfiability of asserted constraints.
|
||||
/// Produce a model that (when the objectives are bounded and
|
||||
/// don't use strict inequalities) meets the objectives.
|
||||
/// </summary>
|
||||
///
|
||||
public Status Check()
|
||||
{
|
||||
Z3_lbool r = (Z3_lbool)Native.Z3_optimize_check(Context.nCtx, NativeObject);
|
||||
switch (r)
|
||||
{
|
||||
case Z3_lbool.Z3_L_TRUE:
|
||||
return Status.SATISFIABLE;
|
||||
case Z3_lbool.Z3_L_FALSE:
|
||||
return Status.UNSATISFIABLE;
|
||||
default:
|
||||
return Status.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a backtracking point.
|
||||
/// </summary>
|
||||
/// <seealso cref="Pop"/>
|
||||
public void Push()
|
||||
{
|
||||
Native.Z3_optimize_push(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Backtrack one backtracking point.
|
||||
/// </summary>
|
||||
/// <remarks>Note that an exception is thrown if Pop is called without a corresponding <c>Push</c></remarks>
|
||||
/// <seealso cref="Push"/>
|
||||
public void Pop()
|
||||
{
|
||||
Native.Z3_optimize_pop(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The model of the last <c>Check</c>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The result is <c>null</c> if <c>Check</c> was not invoked before,
|
||||
/// if its results was not <c>SATISFIABLE</c>, or if model production is not enabled.
|
||||
/// </remarks>
|
||||
public Model Model
|
||||
{
|
||||
get
|
||||
{
|
||||
IntPtr x = Native.Z3_optimize_get_model(Context.nCtx, NativeObject);
|
||||
if (x == IntPtr.Zero)
|
||||
return null;
|
||||
else
|
||||
return new Model(Context, x);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Declare an arithmetical maximization objective.
|
||||
/// Return a handle to the objective. The handle is used as
|
||||
/// to retrieve the values of objectives after calling Check.
|
||||
/// </summary>
|
||||
public Handle MkMaximize(ArithExpr e)
|
||||
{
|
||||
return new Handle(this, Native.Z3_optimize_maximize(Context.nCtx, NativeObject, e.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Declare an arithmetical minimization objective.
|
||||
/// Similar to MkMaximize.
|
||||
/// </summary>
|
||||
public Handle MkMinimize(ArithExpr e)
|
||||
{
|
||||
return new Handle(this, Native.Z3_optimize_minimize(Context.nCtx, NativeObject, e.NativeObject));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve a lower bound for the objective handle.
|
||||
/// </summary>
|
||||
private ArithExpr GetLower(uint index)
|
||||
{
|
||||
return (ArithExpr)Expr.Create(Context, Native.Z3_optimize_get_lower(Context.nCtx, NativeObject, index));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve an upper bound for the objective handle.
|
||||
/// </summary>
|
||||
private ArithExpr GetUpper(uint index)
|
||||
{
|
||||
return (ArithExpr)Expr.Create(Context, Native.Z3_optimize_get_upper(Context.nCtx, NativeObject, index));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return a string the describes why the last to check returned unknown
|
||||
/// </summary>
|
||||
public String getReasonUnknown()
|
||||
{
|
||||
Contract.Ensures(Contract.Result<string>() != null);
|
||||
return Native.Z3_optimize_get_reason_unknown(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Print the context to a string (SMT-LIB parseable benchmark).
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
return Native.Z3_optimize_to_string(Context.nCtx, NativeObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Optimize statistics.
|
||||
/// </summary>
|
||||
public Statistics Statistics
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<Statistics>() != null);
|
||||
|
||||
return new Statistics(Context, Native.Z3_optimize_get_statistics(Context.nCtx, NativeObject));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region Internal
|
||||
internal Optimize(Context ctx, IntPtr obj)
|
||||
: base(ctx, obj)
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
internal Optimize(Context ctx)
|
||||
: base(ctx, Native.Z3_mk_optimize(ctx.nCtx))
|
||||
{
|
||||
Contract.Requires(ctx != null);
|
||||
}
|
||||
|
||||
internal class DecRefQueue : IDecRefQueue
|
||||
{
|
||||
public DecRefQueue() : base() { }
|
||||
public DecRefQueue(uint move_limit) : base(move_limit) { }
|
||||
internal override void IncRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_optimize_inc_ref(ctx.nCtx, obj);
|
||||
}
|
||||
|
||||
internal override void DecRef(Context ctx, IntPtr obj)
|
||||
{
|
||||
Native.Z3_optimize_dec_ref(ctx.nCtx, obj);
|
||||
}
|
||||
};
|
||||
|
||||
internal override void IncRef(IntPtr o)
|
||||
{
|
||||
Context.Optimize_DRQ.IncAndClear(Context, o);
|
||||
base.IncRef(o);
|
||||
}
|
||||
|
||||
internal override void DecRef(IntPtr o)
|
||||
{
|
||||
Context.Optimize_DRQ.Add(o);
|
||||
base.DecRef(o);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -79,6 +79,7 @@ namespace Microsoft.Z3
|
|||
Native.Z3_params_set_symbol(Context.nCtx, NativeObject, name.NativeObject, value.NativeObject);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Adds a parameter setting.
|
||||
/// </summary>
|
||||
|
@ -118,6 +119,7 @@ namespace Microsoft.Z3
|
|||
/// </summary>
|
||||
public void Add(string name, string value)
|
||||
{
|
||||
Contract.Requires(name != null);
|
||||
Contract.Requires(value != null);
|
||||
|
||||
Native.Z3_params_set_symbol(Context.nCtx, NativeObject, Context.MkSymbol(name).NativeObject, Context.MkSymbol(value).NativeObject);
|
||||
|
|
|
@ -178,8 +178,8 @@ namespace Microsoft.Z3
|
|||
{
|
||||
get
|
||||
{
|
||||
ASTVector ass = new ASTVector(Context, Native.Z3_solver_get_assertions(Context.nCtx, NativeObject));
|
||||
return ass.Size;
|
||||
ASTVector assertions = new ASTVector(Context, Native.Z3_solver_get_assertions(Context.nCtx, NativeObject));
|
||||
return assertions.Size;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -192,12 +192,8 @@ namespace Microsoft.Z3
|
|||
{
|
||||
Contract.Ensures(Contract.Result<BoolExpr[]>() != null);
|
||||
|
||||
ASTVector ass = new ASTVector(Context, Native.Z3_solver_get_assertions(Context.nCtx, NativeObject));
|
||||
uint n = ass.Size;
|
||||
BoolExpr[] res = new BoolExpr[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = new BoolExpr(Context, ass[i].NativeObject);
|
||||
return res;
|
||||
ASTVector assertions = new ASTVector(Context, Native.Z3_solver_get_assertions(Context.nCtx, NativeObject));
|
||||
return assertions.ToBoolExprArray();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -270,18 +266,14 @@ namespace Microsoft.Z3
|
|||
/// The result is empty if <c>Check</c> was not invoked before,
|
||||
/// if its results was not <c>UNSATISFIABLE</c>, or if core production is disabled.
|
||||
/// </remarks>
|
||||
public Expr[] UnsatCore
|
||||
public BoolExpr[] UnsatCore
|
||||
{
|
||||
get
|
||||
{
|
||||
Contract.Ensures(Contract.Result<Expr[]>() != null);
|
||||
|
||||
ASTVector core = new ASTVector(Context, Native.Z3_solver_get_unsat_core(Context.nCtx, NativeObject));
|
||||
uint n = core.Size;
|
||||
Expr[] res = new Expr[n];
|
||||
for (uint i = 0; i < n; i++)
|
||||
res[i] = Expr.Create(Context, core[i].NativeObject);
|
||||
return res;
|
||||
ASTVector core = new ASTVector(Context, Native.Z3_solver_get_unsat_core(Context.nCtx, NativeObject));
|
||||
return core.ToBoolExprArray();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,6 +66,47 @@ namespace Microsoft.Z3
|
|||
throw new Z3Exception("Unknown symbol kind encountered");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Equality overloading.
|
||||
/// </summary>
|
||||
public static bool operator ==(Symbol s1, Symbol s2)
|
||||
{
|
||||
|
||||
return Object.ReferenceEquals(s1, s2) ||
|
||||
(!Object.ReferenceEquals(s1, null) &&
|
||||
!Object.ReferenceEquals(s2, null) &&
|
||||
s1.NativeObject == s2.NativeObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Equality overloading.
|
||||
/// </summary>
|
||||
public static bool operator !=(Symbol s1, Symbol s2)
|
||||
{
|
||||
return !(s1.NativeObject == s2.NativeObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Object comparison.
|
||||
/// </summary>
|
||||
public override bool Equals(object o)
|
||||
{
|
||||
Symbol casted = o as Symbol;
|
||||
if (casted == null) return false;
|
||||
return this == casted;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The Symbols's hash code.
|
||||
/// </summary>
|
||||
/// <returns>A hash code</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return (int)NativeObject;
|
||||
}
|
||||
|
||||
|
||||
#region Internal
|
||||
/// <summary>
|
||||
/// Symbol constructor
|
||||
|
|
|
@ -22,10 +22,8 @@ import com.microsoft.z3.enumerations.Z3_ast_kind;
|
|||
/**
|
||||
* The abstract syntax tree (AST) class.
|
||||
**/
|
||||
public class AST extends Z3Object
|
||||
public class AST extends Z3Object implements Comparable
|
||||
{
|
||||
/* Overloaded operators are not translated. */
|
||||
|
||||
/**
|
||||
* Object comparison.
|
||||
*
|
||||
|
@ -35,7 +33,7 @@ public class AST extends Z3Object
|
|||
{
|
||||
AST casted = null;
|
||||
|
||||
try
|
||||
try
|
||||
{
|
||||
casted = AST.class.cast(o);
|
||||
} catch (ClassCastException e)
|
||||
|
@ -43,8 +41,13 @@ public class AST extends Z3Object
|
|||
return false;
|
||||
}
|
||||
|
||||
return this.getNativeObject() == casted.getNativeObject();
|
||||
}
|
||||
return
|
||||
(this == casted) ||
|
||||
(this != null) &&
|
||||
(casted != null) &&
|
||||
(getContext().nCtx() == casted.getContext().nCtx()) &&
|
||||
(Native.isEqAst(getContext().nCtx(), getNativeObject(), casted.getNativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Object Comparison.
|
||||
|
|
|
@ -92,10 +92,10 @@ class ASTMap extends Z3Object
|
|||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public ASTVector getKeys()
|
||||
public AST[] getKeys()
|
||||
{
|
||||
return new ASTVector(getContext(), Native.astMapKeys(getContext().nCtx(),
|
||||
getNativeObject()));
|
||||
ASTVector av = new ASTVector(getContext(), Native.astMapKeys(getContext().nCtx(), getNativeObject()));
|
||||
return av.ToArray();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -119,4 +119,135 @@ public class ASTVector extends Z3Object
|
|||
getContext().getASTVectorDRQ().add(o);
|
||||
super.decRef(o);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates the AST vector into an AST[]
|
||||
* */
|
||||
public AST[] ToArray()
|
||||
{
|
||||
int n = size();
|
||||
AST[] res = new AST[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = AST.create(getContext(), get(i).getNativeObject());
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates the AST vector into an Expr[]
|
||||
* */
|
||||
public Expr[] ToExprArray() {
|
||||
int n = size();
|
||||
Expr[] res = new Expr[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = Expr.create(getContext(), get(i).getNativeObject());
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates the AST vector into an BoolExpr[]
|
||||
* */
|
||||
public BoolExpr[] ToBoolExprArray()
|
||||
{
|
||||
int n = size();
|
||||
BoolExpr[] res = new BoolExpr[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = (BoolExpr) Expr.create(getContext(), get(i).getNativeObject());
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates the AST vector into an BitVecExpr[]
|
||||
* */
|
||||
public BitVecExpr[] ToBitVecExprArray()
|
||||
{
|
||||
int n = size();
|
||||
BitVecExpr[] res = new BitVecExpr[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = (BitVecExpr)Expr.create(getContext(), get(i).getNativeObject());
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates the AST vector into an ArithExpr[]
|
||||
* */
|
||||
public ArithExpr[] ToArithExprExprArray()
|
||||
{
|
||||
int n = size();
|
||||
ArithExpr[] res = new ArithExpr[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = (ArithExpr)Expr.create(getContext(), get(i).getNativeObject());
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates the AST vector into an ArrayExpr[]
|
||||
* */
|
||||
public ArrayExpr[] ToArrayExprArray()
|
||||
{
|
||||
int n = size();
|
||||
ArrayExpr[] res = new ArrayExpr[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = (ArrayExpr)Expr.create(getContext(), get(i).getNativeObject());
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates the AST vector into an DatatypeExpr[]
|
||||
* */
|
||||
public DatatypeExpr[] ToDatatypeExprArray()
|
||||
{
|
||||
int n = size();
|
||||
DatatypeExpr[] res = new DatatypeExpr[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = (DatatypeExpr)Expr.create(getContext(), get(i).getNativeObject());
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates the AST vector into an FPExpr[]
|
||||
* */
|
||||
public FPExpr[] ToFPExprArray()
|
||||
{
|
||||
int n = size();
|
||||
FPExpr[] res = new FPExpr[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = (FPExpr)Expr.create(getContext(), get(i).getNativeObject());
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates the AST vector into an FPRMExpr[]
|
||||
* */
|
||||
public FPRMExpr[] ToFPRMExprArray()
|
||||
{
|
||||
int n = size();
|
||||
FPRMExpr[] res = new FPRMExpr[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = (FPRMExpr)Expr.create(getContext(), get(i).getNativeObject());
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates the AST vector into an IntExpr[]
|
||||
* */
|
||||
public IntExpr[] ToIntExprArray()
|
||||
{
|
||||
int n = size();
|
||||
IntExpr[] res = new IntExpr[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = (IntExpr)Expr.create(getContext(), get(i).getNativeObject());
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates the AST vector into an RealExpr[]
|
||||
* */
|
||||
public RealExpr[] ToRealExprArray()
|
||||
{
|
||||
int n = size();
|
||||
RealExpr[] res = new RealExpr[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = (RealExpr)Expr.create(getContext(), get(i).getNativeObject());
|
||||
return res;
|
||||
}
|
||||
}
|
|
@ -361,6 +361,23 @@ public class Context extends IDisposable
|
|||
return mkDatatypeSorts(mkSymbols(names), c);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a datatype field at expression t with value v.
|
||||
* The function performs a record update at t. The field
|
||||
* that is passed in as argument is updated with value v,
|
||||
* the remainig fields of t are unchanged.
|
||||
**/
|
||||
public Expr MkUpdateField(FuncDecl field, Expr t, Expr v)
|
||||
throws Z3Exception
|
||||
{
|
||||
return Expr.create
|
||||
(this,
|
||||
Native.datatypeUpdateField
|
||||
(nCtx(), field.getNativeObject(),
|
||||
t.getNativeObject(), v.getNativeObject()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new function declaration.
|
||||
**/
|
||||
|
@ -1708,32 +1725,31 @@ public class Context extends IDisposable
|
|||
/**
|
||||
* Create an empty set.
|
||||
**/
|
||||
public Expr mkEmptySet(Sort domain)
|
||||
public ArrayExpr mkEmptySet(Sort domain)
|
||||
{
|
||||
checkContextMatch(domain);
|
||||
return Expr.create(this,
|
||||
return (ArrayExpr)Expr.create(this,
|
||||
Native.mkEmptySet(nCtx(), domain.getNativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the full set.
|
||||
**/
|
||||
public Expr mkFullSet(Sort domain)
|
||||
public ArrayExpr mkFullSet(Sort domain)
|
||||
{
|
||||
checkContextMatch(domain);
|
||||
return Expr.create(this,
|
||||
return (ArrayExpr)Expr.create(this,
|
||||
Native.mkFullSet(nCtx(), domain.getNativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an element to the set.
|
||||
**/
|
||||
public Expr mkSetAdd(Expr set, Expr element)
|
||||
public ArrayExpr mkSetAdd(ArrayExpr set, Expr element)
|
||||
{
|
||||
checkContextMatch(set);
|
||||
checkContextMatch(element);
|
||||
return Expr.create(
|
||||
this,
|
||||
return (ArrayExpr)Expr.create(this,
|
||||
Native.mkSetAdd(nCtx(), set.getNativeObject(),
|
||||
element.getNativeObject()));
|
||||
}
|
||||
|
@ -1741,12 +1757,11 @@ public class Context extends IDisposable
|
|||
/**
|
||||
* Remove an element from a set.
|
||||
**/
|
||||
public Expr mkSetDel(Expr set, Expr element)
|
||||
public ArrayExpr mkSetDel(ArrayExpr set, Expr element)
|
||||
{
|
||||
checkContextMatch(set);
|
||||
checkContextMatch(element);
|
||||
return Expr.create(
|
||||
this,
|
||||
return (ArrayExpr)Expr.create(this,
|
||||
Native.mkSetDel(nCtx(), set.getNativeObject(),
|
||||
element.getNativeObject()));
|
||||
}
|
||||
|
@ -1754,11 +1769,10 @@ public class Context extends IDisposable
|
|||
/**
|
||||
* Take the union of a list of sets.
|
||||
**/
|
||||
public Expr mkSetUnion(Expr... args)
|
||||
public ArrayExpr mkSetUnion(ArrayExpr... args)
|
||||
{
|
||||
checkContextMatch(args);
|
||||
return Expr.create(
|
||||
this,
|
||||
return (ArrayExpr)Expr.create(this,
|
||||
Native.mkSetUnion(nCtx(), (int) args.length,
|
||||
AST.arrayToNative(args)));
|
||||
}
|
||||
|
@ -1766,11 +1780,10 @@ public class Context extends IDisposable
|
|||
/**
|
||||
* Take the intersection of a list of sets.
|
||||
**/
|
||||
public Expr mkSetIntersection(Expr... args)
|
||||
public ArrayExpr mkSetIntersection(ArrayExpr... args)
|
||||
{
|
||||
checkContextMatch(args);
|
||||
return Expr.create(
|
||||
this,
|
||||
return (ArrayExpr)Expr.create(this,
|
||||
Native.mkSetIntersect(nCtx(), (int) args.length,
|
||||
AST.arrayToNative(args)));
|
||||
}
|
||||
|
@ -1778,12 +1791,11 @@ public class Context extends IDisposable
|
|||
/**
|
||||
* Take the difference between two sets.
|
||||
**/
|
||||
public Expr mkSetDifference(Expr arg1, Expr arg2)
|
||||
public ArrayExpr mkSetDifference(ArrayExpr arg1, ArrayExpr arg2)
|
||||
{
|
||||
checkContextMatch(arg1);
|
||||
checkContextMatch(arg2);
|
||||
return Expr.create(
|
||||
this,
|
||||
return (ArrayExpr)Expr.create(this,
|
||||
Native.mkSetDifference(nCtx(), arg1.getNativeObject(),
|
||||
arg2.getNativeObject()));
|
||||
}
|
||||
|
@ -1791,22 +1803,21 @@ public class Context extends IDisposable
|
|||
/**
|
||||
* Take the complement of a set.
|
||||
**/
|
||||
public Expr mkSetComplement(Expr arg)
|
||||
public ArrayExpr mkSetComplement(ArrayExpr arg)
|
||||
{
|
||||
checkContextMatch(arg);
|
||||
return Expr.create(this,
|
||||
return (ArrayExpr)Expr.create(this,
|
||||
Native.mkSetComplement(nCtx(), arg.getNativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for set membership.
|
||||
**/
|
||||
public Expr mkSetMembership(Expr elem, Expr set)
|
||||
public BoolExpr mkSetMembership(Expr elem, ArrayExpr set)
|
||||
{
|
||||
checkContextMatch(elem);
|
||||
checkContextMatch(set);
|
||||
return Expr.create(
|
||||
this,
|
||||
return (BoolExpr) Expr.create(this,
|
||||
Native.mkSetMember(nCtx(), elem.getNativeObject(),
|
||||
set.getNativeObject()));
|
||||
}
|
||||
|
@ -1814,12 +1825,11 @@ public class Context extends IDisposable
|
|||
/**
|
||||
* Check for subsetness of sets.
|
||||
**/
|
||||
public Expr mkSetSubset(Expr arg1, Expr arg2)
|
||||
public BoolExpr mkSetSubset(ArrayExpr arg1, ArrayExpr arg2)
|
||||
{
|
||||
checkContextMatch(arg1);
|
||||
checkContextMatch(arg2);
|
||||
return Expr.create(
|
||||
this,
|
||||
return (BoolExpr) Expr.create(this,
|
||||
Native.mkSetSubset(nCtx(), arg1.getNativeObject(),
|
||||
arg2.getNativeObject()));
|
||||
}
|
||||
|
@ -2786,6 +2796,14 @@ public class Context extends IDisposable
|
|||
return new Fixedpoint(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Optimize context.
|
||||
**/
|
||||
public Optimize mkOptimize()
|
||||
{
|
||||
return new Optimize(this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create the floating-point RoundingMode sort.
|
||||
|
@ -3661,6 +3679,7 @@ public class Context extends IDisposable
|
|||
private StatisticsDecRefQueue m_Statistics_DRQ = new StatisticsDecRefQueue(10);
|
||||
private TacticDecRefQueue m_Tactic_DRQ = new TacticDecRefQueue(10);
|
||||
private FixedpointDecRefQueue m_Fixedpoint_DRQ = new FixedpointDecRefQueue(10);
|
||||
private OptimizeDecRefQueue m_Optimize_DRQ = new OptimizeDecRefQueue(10);
|
||||
|
||||
public IDecRefQueue getASTDRQ()
|
||||
{
|
||||
|
@ -3737,6 +3756,11 @@ public class Context extends IDisposable
|
|||
return m_Fixedpoint_DRQ;
|
||||
}
|
||||
|
||||
public IDecRefQueue getOptimizeDRQ()
|
||||
{
|
||||
return m_Optimize_DRQ;
|
||||
}
|
||||
|
||||
protected long m_refCount = 0;
|
||||
|
||||
/**
|
||||
|
|
|
@ -43,6 +43,21 @@ public class FPNum extends FPExpr
|
|||
return Native.fpaGetNumeralSignificandString(getContext().nCtx(), getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* The significand value of a floating-point numeral as a UInt64
|
||||
* Remarks: This function extracts the significand bits, without the
|
||||
* hidden bit or normalization. Throws an exception if the
|
||||
* significand does not fit into a UInt64.
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public long getSignificandUInt64()
|
||||
{
|
||||
Native.LongPtr res = new Native.LongPtr();
|
||||
if (Native.fpaGetNumeralSignificandUint64(getContext().nCtx(), getNativeObject(), res) ^ true)
|
||||
throw new Z3Exception("Significand is not a 64 bit unsigned integer");
|
||||
return res.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the exponent value of a floating-point numeral as a string
|
||||
* @throws Z3Exception
|
||||
|
|
|
@ -43,7 +43,7 @@ public class FPSort extends Sort
|
|||
* The number of significand bits.
|
||||
*/
|
||||
public int getSBits() {
|
||||
return Native.fpaGetEbits(getContext().nCtx(), getNativeObject());
|
||||
return Native.fpaGetSbits(getContext().nCtx(), getNativeObject());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -213,7 +213,6 @@ public class Fixedpoint extends Z3Object
|
|||
**/
|
||||
public String getReasonUnknown()
|
||||
{
|
||||
|
||||
return Native.fixedpointGetReasonUnknown(getContext().nCtx(),
|
||||
getNativeObject());
|
||||
}
|
||||
|
@ -295,14 +294,8 @@ public class Fixedpoint extends Z3Object
|
|||
**/
|
||||
public BoolExpr[] getRules()
|
||||
{
|
||||
|
||||
ASTVector v = new ASTVector(getContext(), Native.fixedpointGetRules(
|
||||
getContext().nCtx(), getNativeObject()));
|
||||
int n = v.size();
|
||||
BoolExpr[] res = new BoolExpr[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = new BoolExpr(getContext(), v.get(i).getNativeObject());
|
||||
return res;
|
||||
ASTVector v = new ASTVector(getContext(), Native.fixedpointGetRules(getContext().nCtx(), getNativeObject()));
|
||||
return v.ToBoolExprArray();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -312,17 +305,45 @@ public class Fixedpoint extends Z3Object
|
|||
**/
|
||||
public BoolExpr[] getAssertions()
|
||||
{
|
||||
|
||||
ASTVector v = new ASTVector(getContext(), Native.fixedpointGetAssertions(
|
||||
getContext().nCtx(), getNativeObject()));
|
||||
int n = v.size();
|
||||
BoolExpr[] res = new BoolExpr[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = new BoolExpr(getContext(), v.get(i).getNativeObject());
|
||||
return res;
|
||||
ASTVector v = new ASTVector(getContext(), Native.fixedpointGetAssertions(getContext().nCtx(), getNativeObject()));
|
||||
return v.ToBoolExprArray();
|
||||
}
|
||||
|
||||
Fixedpoint(Context ctx, long obj)
|
||||
/**
|
||||
* Fixedpoint statistics.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Statistics getStatistics()
|
||||
{
|
||||
return new Statistics(getContext(), Native.fixedpointGetStatistics(
|
||||
getContext().nCtx(), getNativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse an SMT-LIB2 file with fixedpoint rules.
|
||||
* Add the rules to the current fixedpoint context.
|
||||
* Return the set of queries in the file.
|
||||
**/
|
||||
public BoolExpr[] ParseFile(String file)
|
||||
{
|
||||
ASTVector av = new ASTVector(getContext(), Native.fixedpointFromFile(getContext().nCtx(), getNativeObject(), file));
|
||||
return av.ToBoolExprArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse an SMT-LIB2 string with fixedpoint rules.
|
||||
* Add the rules to the current fixedpoint context.
|
||||
* Return the set of queries in the file.
|
||||
**/
|
||||
public BoolExpr[] ParseString(String s)
|
||||
{
|
||||
ASTVector av = new ASTVector(getContext(), Native.fixedpointFromString(getContext().nCtx(), getNativeObject(), s));
|
||||
return av.ToBoolExprArray();
|
||||
}
|
||||
|
||||
|
||||
Fixedpoint(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
|
|
@ -26,31 +26,25 @@ import com.microsoft.z3.enumerations.Z3_parameter_kind;
|
|||
**/
|
||||
public class FuncDecl extends AST
|
||||
{
|
||||
/**
|
||||
* Comparison operator.
|
||||
*
|
||||
* @return True if {@code a"/> and <paramref name="b} share the
|
||||
* same context and are equal, false otherwise.
|
||||
**/
|
||||
/* Overloaded operators are not translated. */
|
||||
|
||||
/**
|
||||
* Comparison operator.
|
||||
*
|
||||
* @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. */
|
||||
|
||||
/**
|
||||
* Object comparison.
|
||||
**/
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
FuncDecl casted = (FuncDecl) o;
|
||||
if (casted == null)
|
||||
FuncDecl casted = null;
|
||||
|
||||
try {
|
||||
casted = FuncDecl.class.cast(o);
|
||||
} catch (ClassCastException e) {
|
||||
return false;
|
||||
return this == casted;
|
||||
}
|
||||
|
||||
return
|
||||
(this == casted) ||
|
||||
(this != null) &&
|
||||
(casted != null) &&
|
||||
(getContext().nCtx() == casted.getContext().nCtx()) &&
|
||||
(Native.isEqFuncDecl(getContext().nCtx(), getNativeObject(), casted.getNativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -221,6 +221,22 @@ public class Goal extends Z3Object
|
|||
return "Z3Exception: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Goal to BoolExpr conversion.
|
||||
*
|
||||
* Returns a string representation of the Goal.
|
||||
**/
|
||||
public BoolExpr AsBoolExpr() {
|
||||
int n = size();
|
||||
if (n == 0)
|
||||
return getContext().mkTrue();
|
||||
else if (n == 1)
|
||||
return getFormulas()[0];
|
||||
else {
|
||||
return getContext().mkAnd(getFormulas());
|
||||
}
|
||||
}
|
||||
|
||||
Goal(Context ctx, long obj)
|
||||
{
|
||||
|
|
|
@ -73,20 +73,23 @@ public class InterpolationContext extends Context
|
|||
* well documented.
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Expr[] GetInterpolant(Expr pf, Expr pat, Params p)
|
||||
public BoolExpr[] GetInterpolant(Expr pf, Expr pat, Params p)
|
||||
{
|
||||
checkContextMatch(pf);
|
||||
checkContextMatch(pat);
|
||||
checkContextMatch(p);
|
||||
|
||||
ASTVector seq = new ASTVector(this, Native.getInterpolant(nCtx(), pf.getNativeObject(), pat.getNativeObject(), p.getNativeObject()));
|
||||
int n = seq.size();
|
||||
Expr[] res = new Expr[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = Expr.create(this, seq.get(i).getNativeObject());
|
||||
return res;
|
||||
return seq.ToBoolExprArray();
|
||||
}
|
||||
|
||||
public class ComputeInterpolantResult
|
||||
{
|
||||
public Z3_lbool status = Z3_lbool.Z3_L_UNDEF;
|
||||
public BoolExpr[] interp = null;
|
||||
public Model model = null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Computes an interpolant.
|
||||
* Remarks: For more information on interpolation please refer
|
||||
|
@ -94,17 +97,20 @@ public class InterpolationContext extends Context
|
|||
* well documented.
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Z3_lbool ComputeInterpolant(Expr pat, Params p, ASTVector interp, Model model)
|
||||
public ComputeInterpolantResult ComputeInterpolant(Expr pat, Params p)
|
||||
{
|
||||
checkContextMatch(pat);
|
||||
checkContextMatch(p);
|
||||
|
||||
ComputeInterpolantResult res = new ComputeInterpolantResult();
|
||||
Native.LongPtr n_i = new Native.LongPtr();
|
||||
Native.LongPtr n_m = new Native.LongPtr();
|
||||
int r = Native.computeInterpolant(nCtx(), pat.getNativeObject(), p.getNativeObject(), n_i, n_m);
|
||||
interp = new ASTVector(this, n_i.value);
|
||||
model = new Model(this, n_m.value);
|
||||
return Z3_lbool.fromInt(r);
|
||||
res.status = Z3_lbool.fromInt(Native.computeInterpolant(nCtx(), pat.getNativeObject(), p.getNativeObject(), n_i, n_m));
|
||||
if (res.status == Z3_lbool.Z3_L_FALSE)
|
||||
res.interp = (new ASTVector(this, n_i.value)).ToBoolExprArray();
|
||||
if (res.status == Z3_lbool.Z3_L_TRUE)
|
||||
res.model = new Model(this, n_m.value);
|
||||
return res;
|
||||
}
|
||||
|
||||
///
|
||||
|
@ -118,16 +124,23 @@ public class InterpolationContext extends Context
|
|||
return Native.interpolationProfile(nCtx());
|
||||
}
|
||||
|
||||
public class CheckInterpolantResult
|
||||
{
|
||||
public int return_value = 0;
|
||||
public String error = null;
|
||||
}
|
||||
|
||||
///
|
||||
/// Checks the correctness of an interpolant.
|
||||
///
|
||||
/// Remarks: For more information on interpolation please refer
|
||||
/// too the function Z3_check_interpolant in the C/C++ API, which is
|
||||
/// well documented.
|
||||
public int CheckInterpolant(Expr[] cnsts, int[] parents, Expr[] interps, String error, Expr[] theory)
|
||||
public CheckInterpolantResult CheckInterpolant(Expr[] cnsts, int[] parents, BoolExpr[] interps, String error, Expr[] theory)
|
||||
{
|
||||
CheckInterpolantResult res = new CheckInterpolantResult();
|
||||
Native.StringPtr n_err_str = new Native.StringPtr();
|
||||
int r = Native.checkInterpolant(nCtx(),
|
||||
res.return_value = Native.checkInterpolant(nCtx(),
|
||||
cnsts.length,
|
||||
Expr.arrayToNative(cnsts),
|
||||
parents,
|
||||
|
@ -135,41 +148,52 @@ public class InterpolationContext extends Context
|
|||
n_err_str,
|
||||
theory.length,
|
||||
Expr.arrayToNative(theory));
|
||||
error = n_err_str.value;
|
||||
return r;
|
||||
res.error = n_err_str.value;
|
||||
return res;
|
||||
}
|
||||
|
||||
public class ReadInterpolationProblemResult
|
||||
{
|
||||
public int return_value = 0;
|
||||
public Expr[] cnsts;
|
||||
public int[] parents;
|
||||
public String error;
|
||||
public Expr[] theory;
|
||||
};
|
||||
|
||||
///
|
||||
/// Reads an interpolation problem from a file.
|
||||
///
|
||||
/// Remarks: For more information on interpolation please refer
|
||||
/// too the function Z3_read_interpolation_problem in the C/C++ API, which is
|
||||
/// well documented.
|
||||
public int ReadInterpolationProblem(String filename, Expr[] cnsts, int[] parents, String error, Expr[] theory)
|
||||
public ReadInterpolationProblemResult ReadInterpolationProblem(String filename, Expr[] cnsts, int[] parents, String error, Expr[] theory)
|
||||
{
|
||||
ReadInterpolationProblemResult res = new ReadInterpolationProblemResult();
|
||||
|
||||
Native.IntPtr n_num = new Native.IntPtr();
|
||||
Native.IntPtr n_num_theory = new Native.IntPtr();
|
||||
Native.ObjArrayPtr n_cnsts = new Native.ObjArrayPtr();
|
||||
Native.UIntArrayPtr n_parents = new Native.UIntArrayPtr();
|
||||
Native.ObjArrayPtr n_theory = new Native.ObjArrayPtr();
|
||||
Native.StringPtr n_err_str = new Native.StringPtr();
|
||||
int r = Native.readInterpolationProblem(nCtx(), n_num, n_cnsts, n_parents, filename, n_err_str, n_num_theory, n_theory);
|
||||
res.return_value = Native.readInterpolationProblem(nCtx(), n_num, n_cnsts, n_parents, filename, n_err_str, n_num_theory, n_theory);
|
||||
int num = n_num.value;
|
||||
int num_theory = n_num_theory.value;
|
||||
error = n_err_str.value;
|
||||
cnsts = new Expr[num];
|
||||
parents = new int[num];
|
||||
res.error = n_err_str.value;
|
||||
res.cnsts = new Expr[num];
|
||||
res.parents = new int[num];
|
||||
theory = new Expr[num_theory];
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
cnsts[i] = Expr.create(this, n_cnsts.value[i]);
|
||||
parents[i] = n_parents.value[i];
|
||||
res.cnsts[i] = Expr.create(this, n_cnsts.value[i]);
|
||||
res.parents[i] = n_parents.value[i];
|
||||
}
|
||||
for (int i = 0; i < num_theory; i++)
|
||||
theory[i] = Expr.create(this, n_theory.value[i]);
|
||||
return r;
|
||||
res.theory[i] = Expr.create(this, n_theory.value[i]);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Writes an interpolation problem to a file.
|
||||
///
|
||||
|
|
|
@ -273,11 +273,7 @@ public class Model extends Z3Object
|
|||
|
||||
ASTVector nUniv = new ASTVector(getContext(), Native.modelGetSortUniverse(
|
||||
getContext().nCtx(), getNativeObject(), s.getNativeObject()));
|
||||
int n = nUniv.size();
|
||||
Expr[] res = new Expr[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = Expr.create(getContext(), nUniv.get(i).getNativeObject());
|
||||
return res;
|
||||
return nUniv.ToExprArray();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
278
src/api/java/Optimize.java
Normal file
278
src/api/java/Optimize.java
Normal file
|
@ -0,0 +1,278 @@
|
|||
/**
|
||||
Copyright (c) 2015 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
Optimize.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Z3 Java API: Optimizes
|
||||
|
||||
Author:
|
||||
|
||||
Nikolaj Bjorner (nbjorner) 2015-07-16
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
import com.microsoft.z3.enumerations.Z3_lbool;
|
||||
|
||||
|
||||
/**
|
||||
* Object for managing optimizization context
|
||||
**/
|
||||
public class Optimize extends Z3Object
|
||||
{
|
||||
/**
|
||||
* A string that describes all available optimize solver parameters.
|
||||
**/
|
||||
public String getHelp()
|
||||
{
|
||||
return Native.optimizeGetHelp(getContext().nCtx(), getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the optimize solver parameters.
|
||||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public void setParameters(Params value)
|
||||
{
|
||||
Native.optimizeSetParams(getContext().nCtx(), getNativeObject(), value.getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves parameter descriptions for Optimize solver.
|
||||
**/
|
||||
public ParamDescrs getParameterDescriptions()
|
||||
{
|
||||
return new ParamDescrs(getContext(), Native.optimizeGetParamDescrs(getContext().nCtx(), getNativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert a constraint (or multiple) into the optimize solver.
|
||||
**/
|
||||
public void Assert(BoolExpr ... constraints)
|
||||
{
|
||||
getContext().checkContextMatch(constraints);
|
||||
for (BoolExpr a : constraints)
|
||||
{
|
||||
Native.optimizeAssert(getContext().nCtx(), getNativeObject(), a.getNativeObject());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for Assert.
|
||||
**/
|
||||
public void Add(BoolExpr ... constraints)
|
||||
{
|
||||
Assert(constraints);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle to objectives returned by objective functions.
|
||||
**/
|
||||
public class Handle
|
||||
{
|
||||
Optimize opt;
|
||||
int handle;
|
||||
Handle(Optimize opt, int h)
|
||||
{
|
||||
this.opt = opt;
|
||||
this.handle = h;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a lower bound for the objective handle.
|
||||
**/
|
||||
public ArithExpr getLower()
|
||||
{
|
||||
return opt.GetLower(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve an upper bound for the objective handle.
|
||||
**/
|
||||
public ArithExpr getUpper()
|
||||
{
|
||||
return opt.GetUpper(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the value of an objective.
|
||||
**/
|
||||
public ArithExpr getValue()
|
||||
{
|
||||
return getLower();
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a string representation of the handle.
|
||||
**/
|
||||
public String toString()
|
||||
{
|
||||
return getValue().toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert soft constraint
|
||||
*
|
||||
* Return an objective which associates with the group of constraints.
|
||||
*
|
||||
**/
|
||||
|
||||
public Handle AssertSoft(BoolExpr constraint, int weight, String group)
|
||||
{
|
||||
getContext().checkContextMatch(constraint);
|
||||
Symbol s = getContext().mkSymbol(group);
|
||||
return new Handle(this, Native.optimizeAssertSoft(getContext().nCtx(), getNativeObject(), constraint.getNativeObject(), Integer.toString(weight), s.getNativeObject()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check satisfiability of asserted constraints.
|
||||
* Produce a model that (when the objectives are bounded and
|
||||
* don't use strict inequalities) meets the objectives.
|
||||
**/
|
||||
|
||||
public Status Check()
|
||||
{
|
||||
Z3_lbool r = Z3_lbool.fromInt(Native.optimizeCheck(getContext().nCtx(), getNativeObject()));
|
||||
switch (r) {
|
||||
case Z3_L_TRUE:
|
||||
return Status.SATISFIABLE;
|
||||
case Z3_L_FALSE:
|
||||
return Status.UNSATISFIABLE;
|
||||
default:
|
||||
return Status.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a backtracking point.
|
||||
**/
|
||||
public void Push()
|
||||
{
|
||||
Native.optimizePush(getContext().nCtx(), getNativeObject());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Backtrack one backtracking point.
|
||||
*
|
||||
* Note that an exception is thrown if Pop is called without a corresponding Push.
|
||||
**/
|
||||
|
||||
public void Pop()
|
||||
{
|
||||
Native.optimizePop(getContext().nCtx(), getNativeObject());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The model of the last Check.
|
||||
*
|
||||
* The result is null if Check was not invoked before,
|
||||
* if its results was not SATISFIABLE, or if model production is not enabled.
|
||||
**/
|
||||
public Model getModel()
|
||||
{
|
||||
long x = Native.optimizeGetModel(getContext().nCtx(), getNativeObject());
|
||||
if (x == 0)
|
||||
return null;
|
||||
else
|
||||
return new Model(getContext(), x);
|
||||
}
|
||||
|
||||
/**
|
||||
* Declare an arithmetical maximization objective.
|
||||
* Return a handle to the objective. The handle is used as
|
||||
* to retrieve the values of objectives after calling Check.
|
||||
**/
|
||||
public Handle MkMaximize(ArithExpr e)
|
||||
{
|
||||
return new Handle(this, Native.optimizeMaximize(getContext().nCtx(), getNativeObject(), e.getNativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Declare an arithmetical minimization objective.
|
||||
* Similar to MkMaximize.
|
||||
**/
|
||||
public Handle MkMinimize(ArithExpr e)
|
||||
{
|
||||
return new Handle(this, Native.optimizeMinimize(getContext().nCtx(), getNativeObject(), e.getNativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a lower bound for the objective handle.
|
||||
**/
|
||||
private ArithExpr GetLower(int index)
|
||||
{
|
||||
return (ArithExpr)Expr.create(getContext(), Native.optimizeGetLower(getContext().nCtx(), getNativeObject(), index));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve an upper bound for the objective handle.
|
||||
**/
|
||||
private ArithExpr GetUpper(int index)
|
||||
{
|
||||
return (ArithExpr)Expr.create(getContext(), Native.optimizeGetUpper(getContext().nCtx(), getNativeObject(), index));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string the describes why the last to check returned unknown
|
||||
**/
|
||||
public String getReasonUnknown()
|
||||
{
|
||||
return Native.optimizeGetReasonUnknown(getContext().nCtx(),
|
||||
getNativeObject());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print the context to a String (SMT-LIB parseable benchmark).
|
||||
**/
|
||||
public String toString()
|
||||
{
|
||||
return Native.optimizeToString(getContext().nCtx(), getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Optimize statistics.
|
||||
**/
|
||||
public Statistics getStatistics()
|
||||
{
|
||||
return new Statistics(getContext(), Native.optimizeGetStatistics(getContext().nCtx(), getNativeObject()));
|
||||
}
|
||||
|
||||
|
||||
Optimize(Context ctx, long obj) throws Z3Exception
|
||||
{
|
||||
super(ctx, obj);
|
||||
}
|
||||
|
||||
Optimize(Context ctx) throws Z3Exception
|
||||
{
|
||||
super(ctx, Native.mkOptimize(ctx.nCtx()));
|
||||
}
|
||||
|
||||
|
||||
void incRef(long o)
|
||||
{
|
||||
getContext().getOptimizeDRQ().incAndClear(getContext(), o);
|
||||
super.incRef(o);
|
||||
}
|
||||
|
||||
void decRef(long o)
|
||||
{
|
||||
getContext().getOptimizeDRQ().add(o);
|
||||
super.decRef(o);
|
||||
}
|
||||
|
||||
}
|
53
src/api/java/OptimizeDecRefQueue.java
Normal file
53
src/api/java/OptimizeDecRefQueue.java
Normal file
|
@ -0,0 +1,53 @@
|
|||
/**
|
||||
Copyright (c) 2012-2015 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
OptimizeDecRefQueue.java
|
||||
|
||||
Abstract:
|
||||
|
||||
Author:
|
||||
|
||||
@author Christoph Wintersteiger (cwinter) 2012-03-15
|
||||
|
||||
Notes:
|
||||
|
||||
**/
|
||||
|
||||
package com.microsoft.z3;
|
||||
|
||||
class OptimizeDecRefQueue extends IDecRefQueue
|
||||
{
|
||||
public OptimizeDecRefQueue()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public OptimizeDecRefQueue(int move_limit)
|
||||
{
|
||||
super(move_limit);
|
||||
}
|
||||
|
||||
protected void incRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Native.fixedpointIncRef(ctx.nCtx(), obj);
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
// OK.
|
||||
}
|
||||
}
|
||||
|
||||
protected void decRef(Context ctx, long obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
Native.fixedpointDecRef(ctx.nCtx(), obj);
|
||||
} catch (Z3Exception e)
|
||||
{
|
||||
// OK.
|
||||
}
|
||||
}
|
||||
};
|
|
@ -176,8 +176,7 @@ public class Solver extends Z3Object
|
|||
**/
|
||||
public int getNumAssertions()
|
||||
{
|
||||
ASTVector assrts = new ASTVector(getContext(), Native.solverGetAssertions(
|
||||
getContext().nCtx(), getNativeObject()));
|
||||
ASTVector assrts = new ASTVector(getContext(), Native.solverGetAssertions(getContext().nCtx(), getNativeObject()));
|
||||
return assrts.size();
|
||||
}
|
||||
|
||||
|
@ -188,13 +187,8 @@ public class Solver extends Z3Object
|
|||
**/
|
||||
public BoolExpr[] getAssertions()
|
||||
{
|
||||
ASTVector assrts = new ASTVector(getContext(), Native.solverGetAssertions(
|
||||
getContext().nCtx(), getNativeObject()));
|
||||
int n = assrts.size();
|
||||
BoolExpr[] res = new BoolExpr[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = new BoolExpr(getContext(), assrts.get(i).getNativeObject());
|
||||
return res;
|
||||
ASTVector assrts = new ASTVector(getContext(), Native.solverGetAssertions(getContext().nCtx(), getNativeObject()));
|
||||
return assrts.ToBoolExprArray();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -282,16 +276,11 @@ public class Solver extends Z3Object
|
|||
*
|
||||
* @throws Z3Exception
|
||||
**/
|
||||
public Expr[] getUnsatCore()
|
||||
public BoolExpr[] getUnsatCore()
|
||||
{
|
||||
|
||||
ASTVector core = new ASTVector(getContext(), Native.solverGetUnsatCore(
|
||||
getContext().nCtx(), getNativeObject()));
|
||||
int n = core.size();
|
||||
Expr[] res = new Expr[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
res[i] = Expr.create(getContext(), core.get(i).getNativeObject());
|
||||
return res;
|
||||
ASTVector core = new ASTVector(getContext(), Native.solverGetUnsatCore(getContext().nCtx(), getNativeObject()));
|
||||
return core.ToBoolExprArray();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -25,8 +25,6 @@ import com.microsoft.z3.enumerations.Z3_sort_kind;
|
|||
**/
|
||||
public class Sort extends AST
|
||||
{
|
||||
/* Overloaded operators are not translated. */
|
||||
|
||||
/**
|
||||
* Equality operator for objects of type Sort.
|
||||
* @param o
|
||||
|
@ -36,13 +34,18 @@ public class Sort extends AST
|
|||
{
|
||||
Sort casted = null;
|
||||
|
||||
try {
|
||||
casted = Sort.class.cast(o);
|
||||
} catch (ClassCastException e) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
casted = Sort.class.cast(o);
|
||||
} catch (ClassCastException e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.getNativeObject() == casted.getNativeObject();
|
||||
return
|
||||
(this == casted) ||
|
||||
(this != null) &&
|
||||
(casted != null) &&
|
||||
(getContext().nCtx() == casted.getContext().nCtx()) &&
|
||||
(Native.isEqSort(getContext().nCtx(), getNativeObject(), casted.getNativeObject()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -49,6 +49,19 @@ public class Symbol extends Z3Object
|
|||
return getKind() == Z3_symbol_kind.Z3_STRING_SYMBOL;
|
||||
}
|
||||
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
Symbol casted = null;
|
||||
try {
|
||||
casted = Symbol.class.cast(o);
|
||||
}
|
||||
catch (ClassCastException e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.getNativeObject() == casted.getNativeObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* A string representation of the symbol.
|
||||
**/
|
||||
|
|
758
src/api/ml/z3.ml
758
src/api/ml/z3.ml
File diff suppressed because it is too large
Load diff
|
@ -123,7 +123,7 @@ sig
|
|||
end
|
||||
|
||||
(** The abstract syntax tree (AST) module *)
|
||||
module AST :
|
||||
module rec AST :
|
||||
sig
|
||||
type ast
|
||||
|
||||
|
@ -156,6 +156,12 @@ sig
|
|||
@return A new ASTVector *)
|
||||
val translate : ast_vector -> context -> ast_vector
|
||||
|
||||
(** Translates the ASTVector into an (Ast.ast list) *)
|
||||
val to_list : ast_vector -> ast list
|
||||
|
||||
(** Translates the ASTVector into an (Expr.expr list) *)
|
||||
val to_expr_list : ast_vector -> Expr.expr list
|
||||
|
||||
(** Retrieves a string representation of the vector. *)
|
||||
val to_string : ast_vector -> string
|
||||
end
|
||||
|
@ -260,7 +266,7 @@ sig
|
|||
end
|
||||
|
||||
(** The Sort module implements type information for ASTs *)
|
||||
module Sort :
|
||||
and Sort :
|
||||
sig
|
||||
type sort = Sort of AST.ast
|
||||
|
||||
|
@ -291,7 +297,7 @@ sig
|
|||
end
|
||||
|
||||
(** Function declarations *)
|
||||
module rec FuncDecl :
|
||||
and FuncDecl :
|
||||
sig
|
||||
type func_decl = FuncDecl of AST.ast
|
||||
|
||||
|
@ -2155,6 +2161,12 @@ sig
|
|||
(** Return the significand value of a floating-point numeral as a string. *)
|
||||
val get_numeral_significand_string : context -> Expr.expr -> string
|
||||
|
||||
(** Return the significand value of a floating-point numeral as a uint64.
|
||||
Remark: This function extracts the significand bits, without the
|
||||
hidden bit or normalization. Throws an exception if the
|
||||
significand does not fit into a uint64. *)
|
||||
val get_numeral_significand_uint : context -> Expr.expr -> bool * int
|
||||
|
||||
(** Return the exponent value of a floating-point numeral as a string *)
|
||||
val get_numeral_exponent_string : context -> Expr.expr -> string
|
||||
|
||||
|
@ -2641,6 +2653,9 @@ sig
|
|||
|
||||
(** A string representation of the Goal. *)
|
||||
val to_string : goal -> string
|
||||
|
||||
(** Goal to BoolExpr conversion. *)
|
||||
val as_expr : goal -> Expr.expr
|
||||
end
|
||||
|
||||
(** Models
|
||||
|
@ -2751,7 +2766,7 @@ sig
|
|||
(** The finite set of distinct values that represent the interpretation of a sort.
|
||||
{!get_sorts}
|
||||
@return A list of expressions, where each is an element of the universe of the sort *)
|
||||
val sort_universe : model -> Sort.sort -> AST.ast list
|
||||
val sort_universe : model -> Sort.sort -> Expr.expr list
|
||||
|
||||
(** Conversion of models to strings.
|
||||
@return A string representation of the model. *)
|
||||
|
@ -2938,6 +2953,55 @@ sig
|
|||
val interrupt : context -> unit
|
||||
end
|
||||
|
||||
(** Objects that track statistical information. *)
|
||||
module Statistics :
|
||||
sig
|
||||
type statistics
|
||||
|
||||
(** Statistical data is organized into pairs of \[Key, Entry\], where every
|
||||
Entry is either a floating point or integer value. *)
|
||||
module Entry :
|
||||
sig
|
||||
type statistics_entry
|
||||
|
||||
(** The key of the entry. *)
|
||||
val get_key : statistics_entry -> string
|
||||
|
||||
(** The int-value of the entry. *)
|
||||
val get_int : statistics_entry -> int
|
||||
|
||||
(** The float-value of the entry. *)
|
||||
val get_float : statistics_entry -> float
|
||||
|
||||
(** True if the entry is uint-valued. *)
|
||||
val is_int : statistics_entry -> bool
|
||||
|
||||
(** True if the entry is float-valued. *)
|
||||
val is_float : statistics_entry -> bool
|
||||
|
||||
(** The string representation of the the entry's value. *)
|
||||
val to_string_value : statistics_entry -> string
|
||||
|
||||
(** The string representation of the entry (key and value) *)
|
||||
val to_string : statistics_entry -> string
|
||||
end
|
||||
|
||||
(** A string representation of the statistical data. *)
|
||||
val to_string : statistics -> string
|
||||
|
||||
(** The number of statistical data. *)
|
||||
val get_size : statistics -> int
|
||||
|
||||
(** The data entries. *)
|
||||
val get_entries : statistics -> Entry.statistics_entry list
|
||||
|
||||
(** The statistical counters. *)
|
||||
val get_keys : statistics -> string list
|
||||
|
||||
(** The value of a particular statistical counter. *)
|
||||
val get : statistics -> string -> Entry.statistics_entry option
|
||||
end
|
||||
|
||||
(** Solvers *)
|
||||
module Solver :
|
||||
sig
|
||||
|
@ -2946,56 +3010,6 @@ sig
|
|||
|
||||
val string_of_status : status -> string
|
||||
|
||||
(** Objects that track statistical information about solvers. *)
|
||||
module Statistics :
|
||||
sig
|
||||
type statistics
|
||||
|
||||
(** Statistical data is organized into pairs of \[Key, Entry\], where every
|
||||
Entry is either a floating point or integer value.
|
||||
*)
|
||||
module Entry :
|
||||
sig
|
||||
type statistics_entry
|
||||
|
||||
(** The key of the entry. *)
|
||||
val get_key : statistics_entry -> string
|
||||
|
||||
(** The int-value of the entry. *)
|
||||
val get_int : statistics_entry -> int
|
||||
|
||||
(** The float-value of the entry. *)
|
||||
val get_float : statistics_entry -> float
|
||||
|
||||
(** True if the entry is uint-valued. *)
|
||||
val is_int : statistics_entry -> bool
|
||||
|
||||
(** True if the entry is float-valued. *)
|
||||
val is_float : statistics_entry -> bool
|
||||
|
||||
(** The string representation of the the entry's value. *)
|
||||
val to_string_value : statistics_entry -> string
|
||||
|
||||
(** The string representation of the entry (key and value) *)
|
||||
val to_string : statistics_entry -> string
|
||||
end
|
||||
|
||||
(** A string representation of the statistical data. *)
|
||||
val to_string : statistics -> string
|
||||
|
||||
(** The number of statistical data. *)
|
||||
val get_size : statistics -> int
|
||||
|
||||
(** The data entries. *)
|
||||
val get_entries : statistics -> Entry.statistics_entry list
|
||||
|
||||
(** The statistical counters. *)
|
||||
val get_keys : statistics -> string list
|
||||
|
||||
(** The value of a particular statistical counter. *)
|
||||
val get : statistics -> string -> Entry.statistics_entry option
|
||||
end
|
||||
|
||||
(** A string that describes all available solver parameters. *)
|
||||
val get_help : solver -> string
|
||||
|
||||
|
@ -3081,7 +3095,7 @@ sig
|
|||
The unsat core is a subset of [Assertions]
|
||||
The result is empty if [Check] was not invoked before,
|
||||
if its results was not [UNSATISFIABLE], or if core production is disabled. *)
|
||||
val get_unsat_core : solver -> AST.ast list
|
||||
val get_unsat_core : solver -> Expr.expr list
|
||||
|
||||
(** A brief justification of why the last call to [Check] returned [UNKNOWN]. *)
|
||||
val get_reason_unknown : solver -> string
|
||||
|
@ -3122,7 +3136,7 @@ sig
|
|||
val get_help : fixedpoint -> string
|
||||
|
||||
(** Sets the fixedpoint solver parameters. *)
|
||||
val set_params : fixedpoint -> Params.params -> unit
|
||||
val set_parameters : fixedpoint -> Params.params -> unit
|
||||
|
||||
(** Retrieves parameter descriptions for Fixedpoint solver. *)
|
||||
val get_param_descrs : fixedpoint -> Params.ParamDescrs.param_descrs
|
||||
|
@ -3198,8 +3212,104 @@ sig
|
|||
|
||||
(** Create a Fixedpoint context. *)
|
||||
val mk_fixedpoint : context -> fixedpoint
|
||||
|
||||
(** Retrieve statistics information from the last call to #Z3_fixedpoint_query. *)
|
||||
val get_statistics : fixedpoint -> Statistics.statistics
|
||||
|
||||
(** Parse an SMT-LIB2 string with fixedpoint rules.
|
||||
Add the rules to the current fixedpoint context.
|
||||
Return the set of queries in the string. *)
|
||||
val parse_string : fixedpoint -> string -> Expr.expr list
|
||||
|
||||
(** Parse an SMT-LIB2 file with fixedpoint rules.
|
||||
Add the rules to the current fixedpoint context.
|
||||
Return the set of queries in the file. *)
|
||||
val parse_file : fixedpoint -> string -> Expr.expr list
|
||||
end
|
||||
|
||||
(** Optimization *)
|
||||
module Optimize :
|
||||
sig
|
||||
type optimize
|
||||
type handle
|
||||
|
||||
|
||||
(** Create a Optimize context. *)
|
||||
val mk_opt : context -> optimize
|
||||
|
||||
(** A string that describes all available optimize solver parameters. *)
|
||||
val get_help : optimize -> string
|
||||
|
||||
|
||||
(** Sets the optimize solver parameters. *)
|
||||
val set_parameters : optimize -> Params.params -> unit
|
||||
|
||||
|
||||
(** Retrieves parameter descriptions for Optimize solver. *)
|
||||
val get_param_descrs : optimize -> Params.ParamDescrs.param_descrs
|
||||
|
||||
|
||||
(** Assert a constraints into the optimize solver. *)
|
||||
val add : optimize -> Expr.expr list -> unit
|
||||
|
||||
|
||||
(** Asssert a soft constraint.
|
||||
Supply integer weight and string that identifies a group
|
||||
of soft constraints.
|
||||
*)
|
||||
val add_soft : optimize -> Expr.expr -> string -> Symbol.symbol -> handle
|
||||
|
||||
|
||||
(** Add maximization objective.
|
||||
*)
|
||||
val maximize : optimize -> Expr.expr -> handle
|
||||
|
||||
|
||||
(** Add minimization objective.
|
||||
*)
|
||||
val minimize : optimize -> Expr.expr -> handle
|
||||
|
||||
(** Checks whether the assertions in the context are satisfiable and solves objectives.
|
||||
*)
|
||||
val check : optimize -> Solver.status
|
||||
|
||||
|
||||
(** Retrieve model from satisfiable context *)
|
||||
val get_model : optimize -> Model.model option
|
||||
|
||||
|
||||
(** Retrieve lower bound in current model for handle *)
|
||||
val get_lower : handle -> int -> Expr.expr
|
||||
|
||||
|
||||
(** Retrieve upper bound in current model for handle *)
|
||||
val get_upper : handle -> int -> Expr.expr
|
||||
|
||||
|
||||
(** Creates a backtracking point.
|
||||
{!pop} *)
|
||||
val push : optimize -> unit
|
||||
|
||||
|
||||
(** Backtrack one backtracking point.
|
||||
Note that an exception is thrown if Pop is called without a corresponding [Push]
|
||||
{!push} *)
|
||||
val pop : optimize -> unit
|
||||
|
||||
|
||||
(** Retrieve explanation why optimize engine returned status Unknown. *)
|
||||
val get_reason_unknown : optimize -> string
|
||||
|
||||
|
||||
(** Retrieve SMT-LIB string representation of optimize object. *)
|
||||
val to_string : optimize -> string
|
||||
|
||||
|
||||
(** Retrieve statistics information from the last call to check *)
|
||||
val get_statistics : optimize -> Statistics.statistics
|
||||
end
|
||||
|
||||
|
||||
(** Functions for handling SMT and SMT2 expressions and files *)
|
||||
module SMT :
|
||||
sig
|
||||
|
@ -3272,12 +3382,12 @@ sig
|
|||
(** Gets an interpolant.
|
||||
For more information on interpolation please refer
|
||||
too the C/C++ API, which is well documented. *)
|
||||
val get_interpolant : context -> Expr.expr -> Expr.expr -> Params.params -> AST.ASTVector.ast_vector
|
||||
val get_interpolant : context -> Expr.expr -> Expr.expr -> Params.params -> Expr.expr list
|
||||
|
||||
(** Computes an interpolant.
|
||||
For more information on interpolation please refer
|
||||
too the C/C++ API, which is well documented. *)
|
||||
val compute_interpolant : context -> Expr.expr -> Params.params -> (AST.ASTVector.ast_vector * Model.model)
|
||||
val compute_interpolant : context -> Expr.expr -> Params.params -> (Z3enums.lbool * Expr.expr list option * Model.model option)
|
||||
|
||||
(** Retrieves an interpolation profile.
|
||||
For more information on interpolation please refer
|
||||
|
@ -3355,3 +3465,5 @@ val enable_trace : string -> unit
|
|||
*)
|
||||
val disable_trace : string -> unit
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ sat
|
|||
Z3 exceptions:
|
||||
|
||||
>>> try:
|
||||
... x = Int('x')
|
||||
... x = BitVec('x', 32)
|
||||
... y = Bool('y')
|
||||
... # the expression x + y is type incorrect
|
||||
... n = x + y
|
||||
|
@ -301,7 +301,6 @@ class AstRef(Z3PPObject):
|
|||
"""Return unique identifier for object. It can be used for hash-tables and maps."""
|
||||
return Z3_get_ast_id(self.ctx_ref(), self.as_ast())
|
||||
|
||||
|
||||
def ctx_ref(self):
|
||||
"""Return a reference to the C context where this AST node is stored."""
|
||||
return self.ctx.ref()
|
||||
|
@ -455,7 +454,6 @@ class SortRef(AstRef):
|
|||
def get_id(self):
|
||||
return Z3_get_ast_id(self.ctx_ref(), self.as_ast())
|
||||
|
||||
|
||||
def kind(self):
|
||||
"""Return the Z3 internal kind of a sort. This method can be used to test if `self` is one of the Z3 builtin sorts.
|
||||
|
||||
|
@ -555,6 +553,8 @@ def _to_sort_ref(s, ctx):
|
|||
return ArraySortRef(s, ctx)
|
||||
elif k == Z3_DATATYPE_SORT:
|
||||
return DatatypeSortRef(s, ctx)
|
||||
elif k == Z3_FINITE_DOMAIN_SORT:
|
||||
return FiniteDomainSortRef(s, ctx)
|
||||
elif k == Z3_FLOATING_POINT_SORT:
|
||||
return FPSortRef(s, ctx)
|
||||
elif k == Z3_ROUNDING_MODE_SORT:
|
||||
|
@ -1228,6 +1228,16 @@ class BoolSortRef(SortRef):
|
|||
_z3_assert(self.eq(val.sort()), "Value cannot be converted into a Z3 Boolean value")
|
||||
return val
|
||||
|
||||
def subsort(self, other):
|
||||
return isinstance(other, ArithSortRef)
|
||||
|
||||
def is_int(self):
|
||||
return True
|
||||
|
||||
def is_bool(self):
|
||||
return True
|
||||
|
||||
|
||||
class BoolRef(ExprRef):
|
||||
"""All Boolean expressions are instances of this class."""
|
||||
def sort(self):
|
||||
|
@ -1900,6 +1910,10 @@ class ArithSortRef(SortRef):
|
|||
return val
|
||||
if val_s.is_int() and self.is_real():
|
||||
return ToReal(val)
|
||||
if val_s.is_bool() and self.is_int():
|
||||
return If(val, 1, 0)
|
||||
if val_s.is_bool() and self.is_real():
|
||||
return ToReal(If(val, 1, 0))
|
||||
if __debug__:
|
||||
_z3_assert(False, "Z3 Integer/Real expression expected" )
|
||||
else:
|
||||
|
@ -3906,6 +3920,10 @@ class ArrayRef(ExprRef):
|
|||
arg = self.domain().cast(arg)
|
||||
return _to_expr_ref(Z3_mk_select(self.ctx_ref(), self.as_ast(), arg.as_ast()), self.ctx)
|
||||
|
||||
def mk_default(self):
|
||||
return _to_expr_ref(Z3_mk_array_default(self.ctx_ref(), self.as_ast()), self.ctx)
|
||||
|
||||
|
||||
def is_array(a):
|
||||
"""Return `True` if `a` is a Z3 array expression.
|
||||
|
||||
|
@ -3958,6 +3976,14 @@ def is_map(a):
|
|||
"""
|
||||
return is_app_of(a, Z3_OP_ARRAY_MAP)
|
||||
|
||||
def is_default(a):
|
||||
"""Return `True` if `a` is a Z3 default array expression.
|
||||
>>> d = Default(K(IntSort(), 10))
|
||||
>>> is_default(d)
|
||||
True
|
||||
"""
|
||||
return is_app_of(a, Z3_OP_ARRAY_DEFAULT)
|
||||
|
||||
def get_map_func(a):
|
||||
"""Return the function declaration associated with a Z3 map array expression.
|
||||
|
||||
|
@ -4030,6 +4056,17 @@ def Update(a, i, v):
|
|||
ctx = a.ctx
|
||||
return _to_expr_ref(Z3_mk_store(ctx.ref(), a.as_ast(), i.as_ast(), v.as_ast()), ctx)
|
||||
|
||||
def Default(a):
|
||||
""" Return a default value for array expression.
|
||||
>>> b = K(IntSort(), 1)
|
||||
>>> prove(Default(b) == 1)
|
||||
proved
|
||||
"""
|
||||
if __debug__:
|
||||
_z3_assert(is_array(a), "First argument must be a Z3 array expression")
|
||||
return a.mk_default()
|
||||
|
||||
|
||||
def Store(a, i, v):
|
||||
"""Return a Z3 store array expression.
|
||||
|
||||
|
@ -5603,7 +5640,7 @@ class Statistics:
|
|||
sat
|
||||
>>> st = s.statistics()
|
||||
>>> len(st)
|
||||
2
|
||||
6
|
||||
"""
|
||||
return int(Z3_stats_size(self.ctx.ref(), self.stats))
|
||||
|
||||
|
@ -5617,7 +5654,7 @@ class Statistics:
|
|||
sat
|
||||
>>> st = s.statistics()
|
||||
>>> len(st)
|
||||
2
|
||||
6
|
||||
>>> st[0]
|
||||
('nlsat propagations', 2)
|
||||
>>> st[1]
|
||||
|
@ -5641,7 +5678,7 @@ class Statistics:
|
|||
sat
|
||||
>>> st = s.statistics()
|
||||
>>> st.keys()
|
||||
['nlsat propagations', 'nlsat stages']
|
||||
['nlsat propagations', 'nlsat stages', 'rlimit count', 'max memory', 'memory', 'num allocs']
|
||||
"""
|
||||
return [Z3_stats_get_key(self.ctx.ref(), self.stats, idx) for idx in range(len(self))]
|
||||
|
||||
|
@ -5678,7 +5715,7 @@ class Statistics:
|
|||
sat
|
||||
>>> st = s.statistics()
|
||||
>>> st.keys()
|
||||
['nlsat propagations', 'nlsat stages']
|
||||
['nlsat propagations', 'nlsat stages', 'rlimit count', 'max memory', 'memory', 'num allocs']
|
||||
>>> st.nlsat_propagations
|
||||
2
|
||||
>>> st.nlsat_stages
|
||||
|
@ -6071,8 +6108,6 @@ class Solver(Z3PPObject):
|
|||
e = BoolVal(True, self.ctx).as_ast()
|
||||
return Z3_benchmark_to_smtlib_string(self.ctx.ref(), "benchmark generated from python API", "", "unknown", "", sz1, v, e)
|
||||
|
||||
|
||||
|
||||
def SolverFor(logic, ctx=None):
|
||||
"""Create a solver customized for the given logic.
|
||||
|
||||
|
@ -6333,6 +6368,170 @@ class Fixedpoint(Z3PPObject):
|
|||
else:
|
||||
return Exists(self.vars, fml)
|
||||
|
||||
|
||||
#########################################
|
||||
#
|
||||
# Finite domain sorts
|
||||
#
|
||||
#########################################
|
||||
|
||||
class FiniteDomainSortRef(SortRef):
|
||||
"""Finite domain sort."""
|
||||
|
||||
def size(self):
|
||||
"""Return the size of the finite domain sort"""
|
||||
r = (ctype.c_ulonglong * 1)()
|
||||
if Z3_get_finite_domain_sort_size(self.ctx_ref(), self.ast(), r):
|
||||
return r[0]
|
||||
else:
|
||||
raise Z3Exception("Failed to retrieve finite domain sort size")
|
||||
|
||||
def FiniteDomainSort(name, sz, ctx=None):
|
||||
"""Create a named finite domain sort of a given size sz"""
|
||||
ctx = _get_ctx(ctx)
|
||||
return FiniteDomainSortRef(Z3_mk_finite_domain_sort(ctx.ref(), name, sz), ctx)
|
||||
|
||||
#########################################
|
||||
#
|
||||
# Optimize
|
||||
#
|
||||
#########################################
|
||||
|
||||
class OptimizeObjective:
|
||||
def __init__(self, opt, value, is_max):
|
||||
self._opt = opt
|
||||
self._value = value
|
||||
self._is_max = is_max
|
||||
|
||||
def lower(self):
|
||||
opt = self._opt
|
||||
return _to_expr_ref(Z3_optimize_get_lower(opt.ctx.ref(), opt.optimize, self._value), opt.ctx)
|
||||
|
||||
def upper(self):
|
||||
opt = self._opt
|
||||
return _to_expr_ref(Z3_optimize_get_upper(opt.ctx.ref(), opt.optimize, self._value), opt.ctx)
|
||||
|
||||
def value(self):
|
||||
if self._is_max:
|
||||
return self.upper()
|
||||
else:
|
||||
return self.lower()
|
||||
|
||||
class Optimize(Z3PPObject):
|
||||
"""Optimize API provides methods for solving using objective functions and weighted soft constraints"""
|
||||
|
||||
def __init__(self, ctx=None):
|
||||
self.ctx = _get_ctx(ctx)
|
||||
self.optimize = Z3_mk_optimize(self.ctx.ref())
|
||||
Z3_optimize_inc_ref(self.ctx.ref(), self.optimize)
|
||||
|
||||
def __del__(self):
|
||||
if self.optimize != None:
|
||||
Z3_optimize_dec_ref(self.ctx.ref(), self.optimize)
|
||||
|
||||
def set(self, *args, **keys):
|
||||
"""Set a configuration option. The method `help()` return a string containing all available options.
|
||||
"""
|
||||
p = args2params(args, keys, self.ctx)
|
||||
Z3_optimize_set_params(self.ctx.ref(), self.optimize, p.params)
|
||||
|
||||
def help(self):
|
||||
"""Display a string describing all available options."""
|
||||
print(Z3_optimize_get_help(self.ctx.ref(), self.optimize))
|
||||
|
||||
def param_descrs(self):
|
||||
"""Return the parameter description set."""
|
||||
return ParamDescrsRef(Z3_optimize_get_param_descrs(self.ctx.ref(), self.optimize), self.ctx)
|
||||
|
||||
def assert_exprs(self, *args):
|
||||
"""Assert constraints as background axioms for the optimize solver."""
|
||||
args = _get_args(args)
|
||||
for arg in args:
|
||||
if isinstance(arg, Goal) or isinstance(arg, AstVector):
|
||||
for f in arg:
|
||||
Z3_optimize_assert(self.ctx.ref(), self.optimize, f.as_ast())
|
||||
else:
|
||||
Z3_optimize_assert(self.ctx.ref(), self.optimize, arg.as_ast())
|
||||
|
||||
def add(self, *args):
|
||||
"""Assert constraints as background axioms for the optimize solver. Alias for assert_expr."""
|
||||
self.assert_exprs(*args)
|
||||
|
||||
def add_soft(self, arg, weight = "1", id = None):
|
||||
"""Add soft constraint with optional weight and optional identifier.
|
||||
If no weight is supplied, then the penalty for violating the soft constraint
|
||||
is 1.
|
||||
Soft constraints are grouped by identifiers. Soft constraints that are
|
||||
added without identifiers are grouped by default.
|
||||
"""
|
||||
if _is_int(weight):
|
||||
weight = "%d" % weight
|
||||
if not isinstance(weight, str):
|
||||
raise Z3Exception("weight should be a string or an integer")
|
||||
if id == None:
|
||||
id = ""
|
||||
id = to_symbol(id, self.ctx)
|
||||
v = Z3_optimize_assert_soft(self.ctx.ref(), self.optimize, arg.as_ast(), weight, id)
|
||||
return OptimizeObjective(self, v, False)
|
||||
|
||||
def maximize(self, arg):
|
||||
"""Add objective function to maximize."""
|
||||
return OptimizeObjective(self, Z3_optimize_maximize(self.ctx.ref(), self.optimize, arg.as_ast()), True)
|
||||
|
||||
def minimize(self, arg):
|
||||
"""Add objective function to minimize."""
|
||||
return OptimizeObjective(self, Z3_optimize_minimize(self.ctx.ref(), self.optimize, arg.as_ast()), False)
|
||||
|
||||
def push(self):
|
||||
"""create a backtracking point for added rules, facts and assertions"""
|
||||
Z3_optimize_push(self.ctx.ref(), self.optimize)
|
||||
|
||||
def pop(self):
|
||||
"""restore to previously created backtracking point"""
|
||||
Z3_optimize_pop(self.ctx.ref(), self.optimize)
|
||||
|
||||
def check(self):
|
||||
"""Check satisfiability while optimizing objective functions."""
|
||||
return CheckSatResult(Z3_optimize_check(self.ctx.ref(), self.optimize))
|
||||
|
||||
def reason_unknown(self):
|
||||
"""Return a string that describes why the last `check()` returned `unknown`."""
|
||||
return Z3_optimize_get_reason_unknown(self.ctx.ref(), self.optimize)
|
||||
|
||||
def model(self):
|
||||
"""Return a model for the last check()."""
|
||||
try:
|
||||
return ModelRef(Z3_optimize_get_model(self.ctx.ref(), self.optimize), self.ctx)
|
||||
except Z3Exception:
|
||||
raise Z3Exception("model is not available")
|
||||
|
||||
def lower(self, obj):
|
||||
if not isinstance(obj, OptimizeObjective):
|
||||
raise Z3Exception("Expecting objective handle returned by maximize/minimize")
|
||||
return obj.lower()
|
||||
|
||||
def upper(self, obj):
|
||||
if not isinstance(obj, OptimizeObjective):
|
||||
raise Z3Exception("Expecting objective handle returned by maximize/minimize")
|
||||
return obj.upper()
|
||||
|
||||
def __repr__(self):
|
||||
"""Return a formatted string with all added rules and constraints."""
|
||||
return self.sexpr()
|
||||
|
||||
def sexpr(self):
|
||||
"""Return a formatted string (in Lisp-like format) with all added constraints. We say the string is in s-expression format.
|
||||
"""
|
||||
return Z3_optimize_to_string(self.ctx.ref(), self.optimize)
|
||||
|
||||
def statistics(self):
|
||||
"""Return statistics for the last `query()`.
|
||||
"""
|
||||
return Statistics(Z3_optimize_get_statistics(self.ctx.ref(), self.optimize), self.ctx)
|
||||
|
||||
|
||||
|
||||
|
||||
#########################################
|
||||
#
|
||||
# ApplyResult
|
||||
|
@ -8022,23 +8221,24 @@ def FP(name, fpsort, ctx=None):
|
|||
>>> eq(x, x2)
|
||||
True
|
||||
"""
|
||||
ctx = fpsort.ctx
|
||||
if isinstance(fpsort, FPSortRef):
|
||||
ctx = fpsort.ctx
|
||||
else:
|
||||
ctx = _get_ctx(ctx)
|
||||
return FPRef(Z3_mk_const(ctx.ref(), to_symbol(name, ctx), fpsort.ast), ctx)
|
||||
|
||||
def FPs(names, fpsort, ctx=None):
|
||||
"""Return an array of floating-point constants.
|
||||
|
||||
>>> x, y, z = BitVecs('x y z', 16)
|
||||
>>> x.size()
|
||||
16
|
||||
>>> x, y, z = FPs('x y z', FPSort(8, 24))
|
||||
>>> x.sort()
|
||||
BitVec(16)
|
||||
>>> Sum(x, y, z)
|
||||
0 + x + y + z
|
||||
>>> Product(x, y, z)
|
||||
1*x*y*z
|
||||
>>> simplify(Product(x, y, z))
|
||||
x*y*z
|
||||
FPSort(8, 24)
|
||||
>>> x.sbits()
|
||||
24
|
||||
>>> x.ebits()
|
||||
8
|
||||
>>> fpMul(RNE(), fpAdd(RNE(), x, y), z)
|
||||
fpMul(RNE(), fpAdd(RNE(), x, y), z)
|
||||
"""
|
||||
ctx = z3._get_ctx(ctx)
|
||||
if isinstance(names, str):
|
||||
|
|
|
@ -1017,6 +1017,8 @@ class Formatter:
|
|||
return self.pp_seq(a.assertions(), 0, [])
|
||||
elif isinstance(a, z3.Fixedpoint):
|
||||
return a.sexpr()
|
||||
elif isinstance(a, z3.Optimize):
|
||||
return a.sexpr()
|
||||
elif isinstance(a, z3.ApplyResult):
|
||||
return self.pp_seq_seq(a, 0, [])
|
||||
elif isinstance(a, z3.ModelRef):
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
############################################
|
||||
# Copyright (c) 2012 Microsoft Corporation
|
||||
#
|
||||
# Z3 Python interface
|
||||
#
|
||||
# Author: Leonardo de Moura (leonardo)
|
||||
############################################
|
||||
import z3, doctest
|
||||
|
||||
r = doctest.testmod(z3)
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
############################################
|
||||
# Copyright (c) 2012 Microsoft Corporation
|
||||
#
|
||||
# Z3 Python interface
|
||||
#
|
||||
# Author: Leonardo de Moura (leonardo)
|
||||
############################################
|
||||
|
||||
import ctypes, z3core
|
||||
|
||||
class Z3Exception(Exception):
|
||||
|
@ -78,6 +86,10 @@ class FixedpointObj(ctypes.c_void_p):
|
|||
def __init__(self, fixedpoint): self._as_parameter_ = fixedpoint
|
||||
def from_param(obj): return obj
|
||||
|
||||
class OptimizeObj(ctypes.c_void_p):
|
||||
def __init__(self, optimize): self._as_parameter_ = optimize
|
||||
def from_param(obj): return obj
|
||||
|
||||
class ModelObj(ctypes.c_void_p):
|
||||
def __init__(self, model): self._as_parameter_ = model
|
||||
def from_param(obj): return obj
|
||||
|
|
|
@ -1,9 +1,22 @@
|
|||
############################################
|
||||
# Copyright (c) 2012 Microsoft Corporation
|
||||
#
|
||||
# Z3 Python interface
|
||||
#
|
||||
# Authors: Leonardo de Moura (leonardo)
|
||||
# ThanhVu (Vu) Nguyen <tnguyen@cs.unm.edu>
|
||||
############################################
|
||||
"""
|
||||
Usage:
|
||||
import common_z3 as CM_Z3
|
||||
"""
|
||||
|
||||
from z3 import *
|
||||
|
||||
def vset(seq, idfun=None, as_list=True):
|
||||
# This functions preserves the order of arguments while removing duplicates.
|
||||
# This function is from https://code.google.com/p/common-python-vu/source/browse/vu_common.py
|
||||
# It preserves the order of arguments while removing duplicates.
|
||||
# (Thanhu's personal code). It has been copied here to avoid a dependency on vu_common.py.
|
||||
"""
|
||||
order preserving
|
||||
|
||||
|
@ -485,7 +498,7 @@ def model_str(m,as_str=True):
|
|||
|
||||
if m :
|
||||
vs = [(v,m[v]) for v in m]
|
||||
vs = sorted(vs,key=lambda a: str(a[0]))
|
||||
vs = sorted(vs,key=lambda a,_: str(a))
|
||||
if as_str:
|
||||
return '\n'.join(['{} = {}'.format(k,v) for (k,v) in vs])
|
||||
else:
|
||||
|
|
14
src/api/z3.h
14
src/api/z3.h
|
@ -18,8 +18,8 @@ Notes:
|
|||
|
||||
--*/
|
||||
|
||||
#ifndef _Z3__H_
|
||||
#define _Z3__H_
|
||||
#ifndef Z3_H_
|
||||
#define Z3_H_
|
||||
|
||||
#include<stdio.h>
|
||||
#include"z3_macros.h"
|
||||
|
@ -30,15 +30,5 @@ Notes:
|
|||
#include"z3_interp.h"
|
||||
#include"z3_fpa.h"
|
||||
|
||||
#undef __in
|
||||
#undef __out
|
||||
#undef __inout
|
||||
#undef __in_z
|
||||
#undef __out_z
|
||||
#undef __ecount
|
||||
#undef __in_ecount
|
||||
#undef __out_ecount
|
||||
#undef __inout_ecount
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ Notes:
|
|||
|
||||
--*/
|
||||
|
||||
#ifndef _Z3_ALGEBRAIC_H_
|
||||
#define _Z3_ALGEBRAIC_H_
|
||||
#ifndef Z3_ALGEBRAIC_H_
|
||||
#define Z3_ALGEBRAIC_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -43,7 +43,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_algebraic_is_value', BOOL, (_in(CONTEXT), _in(AST)))
|
||||
*/
|
||||
Z3_bool Z3_API Z3_algebraic_is_value(__in Z3_context c, __in Z3_ast a);
|
||||
Z3_bool Z3_API Z3_algebraic_is_value(Z3_context c, Z3_ast a);
|
||||
|
||||
/**
|
||||
\brief Return the Z3_TRUE if \c a is positive, and Z3_FALSE otherwise.
|
||||
|
@ -52,7 +52,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_algebraic_is_pos', BOOL, (_in(CONTEXT), _in(AST)))
|
||||
*/
|
||||
Z3_bool Z3_API Z3_algebraic_is_pos(__in Z3_context c, __in Z3_ast a);
|
||||
Z3_bool Z3_API Z3_algebraic_is_pos(Z3_context c, Z3_ast a);
|
||||
|
||||
/**
|
||||
\brief Return the Z3_TRUE if \c a is negative, and Z3_FALSE otherwise.
|
||||
|
@ -61,7 +61,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_algebraic_is_neg', BOOL, (_in(CONTEXT), _in(AST)))
|
||||
*/
|
||||
Z3_bool Z3_API Z3_algebraic_is_neg(__in Z3_context c, __in Z3_ast a);
|
||||
Z3_bool Z3_API Z3_algebraic_is_neg(Z3_context c, Z3_ast a);
|
||||
|
||||
/**
|
||||
\brief Return the Z3_TRUE if \c a is zero, and Z3_FALSE otherwise.
|
||||
|
@ -70,7 +70,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_algebraic_is_zero', BOOL, (_in(CONTEXT), _in(AST)))
|
||||
*/
|
||||
Z3_bool Z3_API Z3_algebraic_is_zero(__in Z3_context c, __in Z3_ast a);
|
||||
Z3_bool Z3_API Z3_algebraic_is_zero(Z3_context c, Z3_ast a);
|
||||
|
||||
/**
|
||||
\brief Return 1 if \c a is positive, 0 if \c a is zero, and -1 if \c a is negative.
|
||||
|
@ -79,7 +79,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_algebraic_sign', INT, (_in(CONTEXT), _in(AST)))
|
||||
*/
|
||||
int Z3_API Z3_algebraic_sign(__in Z3_context c, __in Z3_ast a);
|
||||
int Z3_API Z3_algebraic_sign(Z3_context c, Z3_ast a);
|
||||
|
||||
/**
|
||||
\brief Return the value a + b.
|
||||
|
@ -90,7 +90,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_algebraic_add', AST, (_in(CONTEXT), _in(AST), _in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_algebraic_add(__in Z3_context c, __in Z3_ast a, __in Z3_ast b);
|
||||
Z3_ast Z3_API Z3_algebraic_add(Z3_context c, Z3_ast a, Z3_ast b);
|
||||
|
||||
/**
|
||||
\brief Return the value a - b.
|
||||
|
@ -101,7 +101,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_algebraic_sub', AST, (_in(CONTEXT), _in(AST), _in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_algebraic_sub(__in Z3_context c, __in Z3_ast a, __in Z3_ast b);
|
||||
Z3_ast Z3_API Z3_algebraic_sub(Z3_context c, Z3_ast a, Z3_ast b);
|
||||
|
||||
/**
|
||||
\brief Return the value a * b.
|
||||
|
@ -112,7 +112,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_algebraic_mul', AST, (_in(CONTEXT), _in(AST), _in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_algebraic_mul(__in Z3_context c, __in Z3_ast a, __in Z3_ast b);
|
||||
Z3_ast Z3_API Z3_algebraic_mul(Z3_context c, Z3_ast a, Z3_ast b);
|
||||
|
||||
/**
|
||||
\brief Return the value a / b.
|
||||
|
@ -124,7 +124,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_algebraic_div', AST, (_in(CONTEXT), _in(AST), _in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_algebraic_div(__in Z3_context c, __in Z3_ast a, __in Z3_ast b);
|
||||
Z3_ast Z3_API Z3_algebraic_div(Z3_context c, Z3_ast a, Z3_ast b);
|
||||
|
||||
/**
|
||||
\brief Return the a^(1/k)
|
||||
|
@ -135,7 +135,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_algebraic_root', AST, (_in(CONTEXT), _in(AST), _in(UINT)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_algebraic_root(__in Z3_context c, __in Z3_ast a, __in unsigned k);
|
||||
Z3_ast Z3_API Z3_algebraic_root(Z3_context c, Z3_ast a, unsigned k);
|
||||
|
||||
/**
|
||||
\brief Return the a^k
|
||||
|
@ -145,7 +145,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_algebraic_power', AST, (_in(CONTEXT), _in(AST), _in(UINT)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_algebraic_power(__in Z3_context c, __in Z3_ast a, __in unsigned k);
|
||||
Z3_ast Z3_API Z3_algebraic_power(Z3_context c, Z3_ast a, unsigned k);
|
||||
|
||||
/**
|
||||
\brief Return Z3_TRUE if a < b, and Z3_FALSE otherwise.
|
||||
|
@ -155,7 +155,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_algebraic_lt', BOOL, (_in(CONTEXT), _in(AST), _in(AST)))
|
||||
*/
|
||||
Z3_bool Z3_API Z3_algebraic_lt(__in Z3_context c, __in Z3_ast a, __in Z3_ast b);
|
||||
Z3_bool Z3_API Z3_algebraic_lt(Z3_context c, Z3_ast a, Z3_ast b);
|
||||
|
||||
/**
|
||||
\brief Return Z3_TRUE if a > b, and Z3_FALSE otherwise.
|
||||
|
@ -165,7 +165,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_algebraic_gt', BOOL, (_in(CONTEXT), _in(AST), _in(AST)))
|
||||
*/
|
||||
Z3_bool Z3_API Z3_algebraic_gt(__in Z3_context c, __in Z3_ast a, __in Z3_ast b);
|
||||
Z3_bool Z3_API Z3_algebraic_gt(Z3_context c, Z3_ast a, Z3_ast b);
|
||||
|
||||
/**
|
||||
\brief Return Z3_TRUE if a <= b, and Z3_FALSE otherwise.
|
||||
|
@ -175,7 +175,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_algebraic_le', BOOL, (_in(CONTEXT), _in(AST), _in(AST)))
|
||||
*/
|
||||
Z3_bool Z3_API Z3_algebraic_le(__in Z3_context c, __in Z3_ast a, __in Z3_ast b);
|
||||
Z3_bool Z3_API Z3_algebraic_le(Z3_context c, Z3_ast a, Z3_ast b);
|
||||
|
||||
/**
|
||||
\brief Return Z3_TRUE if a >= b, and Z3_FALSE otherwise.
|
||||
|
@ -185,7 +185,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_algebraic_ge', BOOL, (_in(CONTEXT), _in(AST), _in(AST)))
|
||||
*/
|
||||
Z3_bool Z3_API Z3_algebraic_ge(__in Z3_context c, __in Z3_ast a, __in Z3_ast b);
|
||||
Z3_bool Z3_API Z3_algebraic_ge(Z3_context c, Z3_ast a, Z3_ast b);
|
||||
|
||||
/**
|
||||
\brief Return Z3_TRUE if a == b, and Z3_FALSE otherwise.
|
||||
|
@ -195,7 +195,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_algebraic_eq', BOOL, (_in(CONTEXT), _in(AST), _in(AST)))
|
||||
*/
|
||||
Z3_bool Z3_API Z3_algebraic_eq(__in Z3_context c, __in Z3_ast a, __in Z3_ast b);
|
||||
Z3_bool Z3_API Z3_algebraic_eq(Z3_context c, Z3_ast a, Z3_ast b);
|
||||
|
||||
/**
|
||||
\brief Return Z3_TRUE if a != b, and Z3_FALSE otherwise.
|
||||
|
@ -205,7 +205,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_algebraic_neq', BOOL, (_in(CONTEXT), _in(AST), _in(AST)))
|
||||
*/
|
||||
Z3_bool Z3_API Z3_algebraic_neq(__in Z3_context c, __in Z3_ast a, __in Z3_ast b);
|
||||
Z3_bool Z3_API Z3_algebraic_neq(Z3_context c, Z3_ast a, Z3_ast b);
|
||||
|
||||
/**
|
||||
\brief Given a multivariate polynomial p(x_0, ..., x_{n-1}, x_n), returns the
|
||||
|
@ -217,7 +217,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_algebraic_roots', AST_VECTOR, (_in(CONTEXT), _in(AST), _in(UINT), _in_array(2, AST)))
|
||||
*/
|
||||
Z3_ast_vector Z3_API Z3_algebraic_roots(__in Z3_context c, __in Z3_ast p, __in unsigned n, __in Z3_ast a[]);
|
||||
Z3_ast_vector Z3_API Z3_algebraic_roots(Z3_context c, Z3_ast p, unsigned n, Z3_ast a[]);
|
||||
|
||||
/**
|
||||
\brief Given a multivariate polynomial p(x_0, ..., x_{n-1}), return the
|
||||
|
@ -228,7 +228,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_algebraic_eval', INT, (_in(CONTEXT), _in(AST), _in(UINT), _in_array(2, AST)))
|
||||
*/
|
||||
int Z3_API Z3_algebraic_eval(__in Z3_context c, __in Z3_ast p, __in unsigned n, __in Z3_ast a[]);
|
||||
int Z3_API Z3_algebraic_eval(Z3_context c, Z3_ast p, unsigned n, Z3_ast a[]);
|
||||
|
||||
/*@}*/
|
||||
/*@}*/
|
||||
|
|
1708
src/api/z3_api.h
1708
src/api/z3_api.h
File diff suppressed because it is too large
Load diff
156
src/api/z3_fpa.h
156
src/api/z3_fpa.h
|
@ -16,8 +16,8 @@ Author:
|
|||
Notes:
|
||||
|
||||
--*/
|
||||
#ifndef _Z3_FPA_H_
|
||||
#define _Z3_FPA_H_
|
||||
#ifndef Z3_FPA_H_
|
||||
#define Z3_FPA_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -42,7 +42,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_rounding_mode_sort', SORT, (_in(CONTEXT),))
|
||||
*/
|
||||
Z3_sort Z3_API Z3_mk_fpa_rounding_mode_sort(__in Z3_context c);
|
||||
Z3_sort Z3_API Z3_mk_fpa_rounding_mode_sort(Z3_context c);
|
||||
|
||||
/**
|
||||
\brief Create a numeral of RoundingMode sort which represents the NearestTiesToEven rounding mode.
|
||||
|
@ -51,7 +51,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_round_nearest_ties_to_even', AST, (_in(CONTEXT),))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_round_nearest_ties_to_even(__in Z3_context c);
|
||||
Z3_ast Z3_API Z3_mk_fpa_round_nearest_ties_to_even(Z3_context c);
|
||||
|
||||
/**
|
||||
\brief Create a numeral of RoundingMode sort which represents the NearestTiesToEven rounding mode.
|
||||
|
@ -60,7 +60,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_rne', AST, (_in(CONTEXT),))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_rne(__in Z3_context c);
|
||||
Z3_ast Z3_API Z3_mk_fpa_rne(Z3_context c);
|
||||
|
||||
/**
|
||||
\brief Create a numeral of RoundingMode sort which represents the NearestTiesToAway rounding mode.
|
||||
|
@ -69,7 +69,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_round_nearest_ties_to_away', AST, (_in(CONTEXT),))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_round_nearest_ties_to_away(__in Z3_context c);
|
||||
Z3_ast Z3_API Z3_mk_fpa_round_nearest_ties_to_away(Z3_context c);
|
||||
|
||||
/**
|
||||
\brief Create a numeral of RoundingMode sort which represents the NearestTiesToAway rounding mode.
|
||||
|
@ -78,7 +78,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_rna', AST, (_in(CONTEXT),))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_rna(__in Z3_context c);
|
||||
Z3_ast Z3_API Z3_mk_fpa_rna(Z3_context c);
|
||||
|
||||
/**
|
||||
\brief Create a numeral of RoundingMode sort which represents the TowardPositive rounding mode.
|
||||
|
@ -87,7 +87,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_round_toward_positive', AST, (_in(CONTEXT),))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_round_toward_positive(__in Z3_context c);
|
||||
Z3_ast Z3_API Z3_mk_fpa_round_toward_positive(Z3_context c);
|
||||
|
||||
/**
|
||||
\brief Create a numeral of RoundingMode sort which represents the TowardPositive rounding mode.
|
||||
|
@ -96,7 +96,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_rtp', AST, (_in(CONTEXT),))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_rtp(__in Z3_context c);
|
||||
Z3_ast Z3_API Z3_mk_fpa_rtp(Z3_context c);
|
||||
|
||||
/**
|
||||
\brief Create a numeral of RoundingMode sort which represents the TowardNegative rounding mode.
|
||||
|
@ -105,7 +105,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_round_toward_negative', AST, (_in(CONTEXT),))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_round_toward_negative(__in Z3_context c);
|
||||
Z3_ast Z3_API Z3_mk_fpa_round_toward_negative(Z3_context c);
|
||||
|
||||
/**
|
||||
\brief Create a numeral of RoundingMode sort which represents the TowardNegative rounding mode.
|
||||
|
@ -114,7 +114,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_rtn', AST, (_in(CONTEXT),))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_rtn(__in Z3_context c);
|
||||
Z3_ast Z3_API Z3_mk_fpa_rtn(Z3_context c);
|
||||
|
||||
/**
|
||||
\brief Create a numeral of RoundingMode sort which represents the TowardZero rounding mode.
|
||||
|
@ -123,7 +123,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_round_toward_zero', AST, (_in(CONTEXT),))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_round_toward_zero(__in Z3_context c);
|
||||
Z3_ast Z3_API Z3_mk_fpa_round_toward_zero(Z3_context c);
|
||||
|
||||
/**
|
||||
\brief Create a numeral of RoundingMode sort which represents the TowardZero rounding mode.
|
||||
|
@ -132,7 +132,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_rtz', AST, (_in(CONTEXT),))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_rtz(__in Z3_context c);
|
||||
Z3_ast Z3_API Z3_mk_fpa_rtz(Z3_context c);
|
||||
|
||||
/**
|
||||
\brief Create a FloatingPoint sort.
|
||||
|
@ -145,7 +145,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_sort', SORT, (_in(CONTEXT), _in(UINT), _in(UINT)))
|
||||
*/
|
||||
Z3_sort Z3_API Z3_mk_fpa_sort(__in Z3_context c, __in unsigned ebits, __in unsigned sbits);
|
||||
Z3_sort Z3_API Z3_mk_fpa_sort(Z3_context c, unsigned ebits, unsigned sbits);
|
||||
|
||||
/**
|
||||
\brief Create the half-precision (16-bit) FloatingPoint sort.
|
||||
|
@ -154,7 +154,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_sort_half', SORT, (_in(CONTEXT),))
|
||||
*/
|
||||
Z3_sort Z3_API Z3_mk_fpa_sort_half(__in Z3_context c);
|
||||
Z3_sort Z3_API Z3_mk_fpa_sort_half(Z3_context c);
|
||||
|
||||
/**
|
||||
\brief Create the half-precision (16-bit) FloatingPoint sort.
|
||||
|
@ -163,7 +163,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_sort_16', SORT, (_in(CONTEXT),))
|
||||
*/
|
||||
Z3_sort Z3_API Z3_mk_fpa_sort_16(__in Z3_context c);
|
||||
Z3_sort Z3_API Z3_mk_fpa_sort_16(Z3_context c);
|
||||
|
||||
/**
|
||||
\brief Create the single-precision (32-bit) FloatingPoint sort.
|
||||
|
@ -172,7 +172,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_sort_single', SORT, (_in(CONTEXT),))
|
||||
*/
|
||||
Z3_sort Z3_API Z3_mk_fpa_sort_single(__in Z3_context c);
|
||||
Z3_sort Z3_API Z3_mk_fpa_sort_single(Z3_context c);
|
||||
|
||||
/**
|
||||
\brief Create the single-precision (32-bit) FloatingPoint sort.
|
||||
|
@ -181,7 +181,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_sort_32', SORT, (_in(CONTEXT),))
|
||||
*/
|
||||
Z3_sort Z3_API Z3_mk_fpa_sort_32(__in Z3_context c);
|
||||
Z3_sort Z3_API Z3_mk_fpa_sort_32(Z3_context c);
|
||||
|
||||
/**
|
||||
\brief Create the double-precision (64-bit) FloatingPoint sort.
|
||||
|
@ -190,7 +190,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_sort_double', SORT, (_in(CONTEXT),))
|
||||
*/
|
||||
Z3_sort Z3_API Z3_mk_fpa_sort_double(__in Z3_context c);
|
||||
Z3_sort Z3_API Z3_mk_fpa_sort_double(Z3_context c);
|
||||
|
||||
/**
|
||||
\brief Create the double-precision (64-bit) FloatingPoint sort.
|
||||
|
@ -199,7 +199,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_sort_64', SORT, (_in(CONTEXT),))
|
||||
*/
|
||||
Z3_sort Z3_API Z3_mk_fpa_sort_64(__in Z3_context c);
|
||||
Z3_sort Z3_API Z3_mk_fpa_sort_64(Z3_context c);
|
||||
|
||||
/**
|
||||
\brief Create the quadruple-precision (128-bit) FloatingPoint sort.
|
||||
|
@ -208,7 +208,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_sort_quadruple', SORT, (_in(CONTEXT),))
|
||||
*/
|
||||
Z3_sort Z3_API Z3_mk_fpa_sort_quadruple(__in Z3_context c);
|
||||
Z3_sort Z3_API Z3_mk_fpa_sort_quadruple(Z3_context c);
|
||||
|
||||
/**
|
||||
\brief Create the quadruple-precision (128-bit) FloatingPoint sort.
|
||||
|
@ -217,7 +217,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_sort_128', SORT, (_in(CONTEXT),))
|
||||
*/
|
||||
Z3_sort Z3_API Z3_mk_fpa_sort_128(__in Z3_context c);
|
||||
Z3_sort Z3_API Z3_mk_fpa_sort_128(Z3_context c);
|
||||
|
||||
/**
|
||||
\brief Create a floating-point NaN of sort s.
|
||||
|
@ -227,7 +227,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_nan', AST, (_in(CONTEXT),_in(SORT)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_nan(__in Z3_context c, __in Z3_sort s);
|
||||
Z3_ast Z3_API Z3_mk_fpa_nan(Z3_context c, Z3_sort s);
|
||||
|
||||
/**
|
||||
\brief Create a floating-point infinity of sort s.
|
||||
|
@ -240,7 +240,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_inf', AST, (_in(CONTEXT),_in(SORT),_in(BOOL)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_inf(__in Z3_context c, __in Z3_sort s, __in Z3_bool negative);
|
||||
Z3_ast Z3_API Z3_mk_fpa_inf(Z3_context c, Z3_sort s, Z3_bool negative);
|
||||
|
||||
/**
|
||||
\brief Create a floating-point zero of sort s.
|
||||
|
@ -253,7 +253,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_zero', AST, (_in(CONTEXT),_in(SORT),_in(BOOL)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_zero(__in Z3_context c, __in Z3_sort s, __in Z3_bool negative);
|
||||
Z3_ast Z3_API Z3_mk_fpa_zero(Z3_context c, Z3_sort s, Z3_bool negative);
|
||||
|
||||
/**
|
||||
\brief Create an expression of FloatingPoint sort from three bit-vector expressions.
|
||||
|
@ -271,7 +271,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_fp', AST, (_in(CONTEXT), _in(AST), _in(AST), _in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_fp(__in Z3_context c, __in Z3_ast sgn, __in Z3_ast exp, __in Z3_ast sig);
|
||||
Z3_ast Z3_API Z3_mk_fpa_fp(Z3_context c, Z3_ast sgn, Z3_ast exp, Z3_ast sig);
|
||||
|
||||
/**
|
||||
\brief Create a numeral of FloatingPoint sort from a float.
|
||||
|
@ -289,7 +289,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_numeral_float', AST, (_in(CONTEXT), _in(FLOAT), _in(SORT)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_numeral_float(__in Z3_context c, __in float v, __in Z3_sort ty);
|
||||
Z3_ast Z3_API Z3_mk_fpa_numeral_float(Z3_context c, float v, Z3_sort ty);
|
||||
|
||||
/**
|
||||
\brief Create a numeral of FloatingPoint sort from a double.
|
||||
|
@ -307,7 +307,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_numeral_double', AST, (_in(CONTEXT), _in(DOUBLE), _in(SORT)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_numeral_double(__in Z3_context c, __in double v, __in Z3_sort ty);
|
||||
Z3_ast Z3_API Z3_mk_fpa_numeral_double(Z3_context c, double v, Z3_sort ty);
|
||||
|
||||
/**
|
||||
\brief Create a numeral of FloatingPoint sort from a signed integer.
|
||||
|
@ -322,7 +322,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_numeral_int', AST, (_in(CONTEXT), _in(INT), _in(SORT)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_numeral_int(__in Z3_context c, __in signed v, Z3_sort ty);
|
||||
Z3_ast Z3_API Z3_mk_fpa_numeral_int(Z3_context c, signed v, Z3_sort ty);
|
||||
|
||||
/**
|
||||
\brief Create a numeral of FloatingPoint sort from a sign bit and two integers.
|
||||
|
@ -339,7 +339,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_numeral_int_uint', AST, (_in(CONTEXT), _in(BOOL), _in(INT), _in(UINT), _in(SORT)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_numeral_int_uint(__in Z3_context c, __in Z3_bool sgn, __in signed exp, __in unsigned sig, Z3_sort ty);
|
||||
Z3_ast Z3_API Z3_mk_fpa_numeral_int_uint(Z3_context c, Z3_bool sgn, signed exp, unsigned sig, Z3_sort ty);
|
||||
|
||||
/**
|
||||
\brief Create a numeral of FloatingPoint sort from a sign bit and two 64-bit integers.
|
||||
|
@ -356,7 +356,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_numeral_int64_uint64', AST, (_in(CONTEXT), _in(BOOL), _in(INT64), _in(UINT64), _in(SORT)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_numeral_int64_uint64(__in Z3_context c, __in Z3_bool sgn, __in __int64 exp, __in __uint64 sig, Z3_sort ty);
|
||||
Z3_ast Z3_API Z3_mk_fpa_numeral_int64_uint64(Z3_context c, Z3_bool sgn, __int64 exp, __uint64 sig, Z3_sort ty);
|
||||
|
||||
/**
|
||||
\brief Floating-point absolute value
|
||||
|
@ -366,7 +366,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_abs', AST, (_in(CONTEXT),_in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_abs(__in Z3_context c, __in Z3_ast t);
|
||||
Z3_ast Z3_API Z3_mk_fpa_abs(Z3_context c, Z3_ast t);
|
||||
|
||||
/**
|
||||
\brief Floating-point negation
|
||||
|
@ -376,7 +376,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_neg', AST, (_in(CONTEXT),_in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_neg(__in Z3_context c, __in Z3_ast t);
|
||||
Z3_ast Z3_API Z3_mk_fpa_neg(Z3_context c, Z3_ast t);
|
||||
|
||||
/**
|
||||
\brief Floating-point addition
|
||||
|
@ -390,7 +390,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_add', AST, (_in(CONTEXT),_in(AST),_in(AST),_in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_add(__in Z3_context c, __in Z3_ast rm, __in Z3_ast t1, __in Z3_ast t2);
|
||||
Z3_ast Z3_API Z3_mk_fpa_add(Z3_context c, Z3_ast rm, Z3_ast t1, Z3_ast t2);
|
||||
|
||||
/**
|
||||
\brief Floating-point subtraction
|
||||
|
@ -404,7 +404,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_sub', AST, (_in(CONTEXT),_in(AST),_in(AST),_in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_sub(__in Z3_context c, __in Z3_ast rm, __in Z3_ast t1, __in Z3_ast t2);
|
||||
Z3_ast Z3_API Z3_mk_fpa_sub(Z3_context c, Z3_ast rm, Z3_ast t1, Z3_ast t2);
|
||||
|
||||
/**
|
||||
\brief Floating-point multiplication
|
||||
|
@ -418,7 +418,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_mul', AST, (_in(CONTEXT),_in(AST),_in(AST),_in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_mul(__in Z3_context c, __in Z3_ast rm, __in Z3_ast t1, __in Z3_ast t2);
|
||||
Z3_ast Z3_API Z3_mk_fpa_mul(Z3_context c, Z3_ast rm, Z3_ast t1, Z3_ast t2);
|
||||
|
||||
/**
|
||||
\brief Floating-point division
|
||||
|
@ -432,7 +432,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_div', AST, (_in(CONTEXT),_in(AST),_in(AST),_in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_div(__in Z3_context c, __in Z3_ast rm, __in Z3_ast t1, __in Z3_ast t2);
|
||||
Z3_ast Z3_API Z3_mk_fpa_div(Z3_context c, Z3_ast rm, Z3_ast t1, Z3_ast t2);
|
||||
|
||||
/**
|
||||
\brief Floating-point fused multiply-add.
|
||||
|
@ -449,7 +449,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_fma', AST, (_in(CONTEXT),_in(AST),_in(AST),_in(AST),_in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_fma(__in Z3_context c, __in Z3_ast rm, __in Z3_ast t1, __in Z3_ast t2, __in Z3_ast t3);
|
||||
Z3_ast Z3_API Z3_mk_fpa_fma(Z3_context c, Z3_ast rm, Z3_ast t1, Z3_ast t2, Z3_ast t3);
|
||||
|
||||
/**
|
||||
\brief Floating-point square root
|
||||
|
@ -462,7 +462,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_sqrt', AST, (_in(CONTEXT),_in(AST),_in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_sqrt(__in Z3_context c, __in Z3_ast rm, __in Z3_ast t);
|
||||
Z3_ast Z3_API Z3_mk_fpa_sqrt(Z3_context c, Z3_ast rm, Z3_ast t);
|
||||
|
||||
/**
|
||||
\brief Floating-point remainder
|
||||
|
@ -475,7 +475,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_rem', AST, (_in(CONTEXT),_in(AST),_in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_rem(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2);
|
||||
Z3_ast Z3_API Z3_mk_fpa_rem(Z3_context c, Z3_ast t1, Z3_ast t2);
|
||||
|
||||
/**
|
||||
\brief Floating-point roundToIntegral. Rounds a floating-point number to
|
||||
|
@ -489,7 +489,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_round_to_integral', AST, (_in(CONTEXT),_in(AST),_in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_round_to_integral(__in Z3_context c, __in Z3_ast rm, __in Z3_ast t);
|
||||
Z3_ast Z3_API Z3_mk_fpa_round_to_integral(Z3_context c, Z3_ast rm, Z3_ast t);
|
||||
|
||||
/**
|
||||
\brief Minimum of floating-point numbers.
|
||||
|
@ -502,7 +502,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_min', AST, (_in(CONTEXT),_in(AST),_in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_min(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2);
|
||||
Z3_ast Z3_API Z3_mk_fpa_min(Z3_context c, Z3_ast t1, Z3_ast t2);
|
||||
|
||||
/**
|
||||
\brief Maximum of floating-point numbers.
|
||||
|
@ -515,7 +515,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_max', AST, (_in(CONTEXT),_in(AST),_in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_max(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2);
|
||||
Z3_ast Z3_API Z3_mk_fpa_max(Z3_context c, Z3_ast t1, Z3_ast t2);
|
||||
|
||||
/**
|
||||
\brief Floating-point less than or equal.
|
||||
|
@ -528,7 +528,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_leq', AST, (_in(CONTEXT),_in(AST),_in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_leq(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2);
|
||||
Z3_ast Z3_API Z3_mk_fpa_leq(Z3_context c, Z3_ast t1, Z3_ast t2);
|
||||
|
||||
/**
|
||||
\brief Floating-point less than.
|
||||
|
@ -541,7 +541,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_lt', AST, (_in(CONTEXT),_in(AST),_in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_lt(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2);
|
||||
Z3_ast Z3_API Z3_mk_fpa_lt(Z3_context c, Z3_ast t1, Z3_ast t2);
|
||||
|
||||
/**
|
||||
\brief Floating-point greater than or equal.
|
||||
|
@ -554,7 +554,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_geq', AST, (_in(CONTEXT),_in(AST),_in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_geq(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2);
|
||||
Z3_ast Z3_API Z3_mk_fpa_geq(Z3_context c, Z3_ast t1, Z3_ast t2);
|
||||
|
||||
/**
|
||||
\brief Floating-point greater than.
|
||||
|
@ -567,7 +567,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_gt', AST, (_in(CONTEXT),_in(AST),_in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_gt(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2);
|
||||
Z3_ast Z3_API Z3_mk_fpa_gt(Z3_context c, Z3_ast t1, Z3_ast t2);
|
||||
|
||||
/**
|
||||
\brief Floating-point equality.
|
||||
|
@ -582,7 +582,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_eq', AST, (_in(CONTEXT),_in(AST),_in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_eq(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2);
|
||||
Z3_ast Z3_API Z3_mk_fpa_eq(Z3_context c, Z3_ast t1, Z3_ast t2);
|
||||
|
||||
/**
|
||||
\brief Predicate indicating whether t is a normal floating-point number.
|
||||
|
@ -594,7 +594,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_is_normal', AST, (_in(CONTEXT),_in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_is_normal(__in Z3_context c, __in Z3_ast t);
|
||||
Z3_ast Z3_API Z3_mk_fpa_is_normal(Z3_context c, Z3_ast t);
|
||||
|
||||
/**
|
||||
\brief Predicate indicating whether t is a subnormal floating-point number.
|
||||
|
@ -606,7 +606,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_is_subnormal', AST, (_in(CONTEXT),_in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_is_subnormal(__in Z3_context c, __in Z3_ast t);
|
||||
Z3_ast Z3_API Z3_mk_fpa_is_subnormal(Z3_context c, Z3_ast t);
|
||||
|
||||
/**
|
||||
\brief Predicate indicating whether t is a floating-point number with zero value, i.e., +zero or -zero.
|
||||
|
@ -618,7 +618,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_is_zero', AST, (_in(CONTEXT),_in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_is_zero(__in Z3_context c, __in Z3_ast t);
|
||||
Z3_ast Z3_API Z3_mk_fpa_is_zero(Z3_context c, Z3_ast t);
|
||||
|
||||
/**
|
||||
\brief Predicate indicating whether t is a floating-point number representing +oo or -oo.
|
||||
|
@ -630,7 +630,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_is_infinite', AST, (_in(CONTEXT),_in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_is_infinite(__in Z3_context c, __in Z3_ast t);
|
||||
Z3_ast Z3_API Z3_mk_fpa_is_infinite(Z3_context c, Z3_ast t);
|
||||
|
||||
/**
|
||||
\brief Predicate indicating whether t is a NaN.
|
||||
|
@ -642,7 +642,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_is_nan', AST, (_in(CONTEXT),_in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_is_nan(__in Z3_context c, __in Z3_ast t);
|
||||
Z3_ast Z3_API Z3_mk_fpa_is_nan(Z3_context c, Z3_ast t);
|
||||
|
||||
/**
|
||||
\brief Predicate indicating whether t is a negative floating-point number.
|
||||
|
@ -654,7 +654,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_is_negative', AST, (_in(CONTEXT),_in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_is_negative(__in Z3_context c, __in Z3_ast t);
|
||||
Z3_ast Z3_API Z3_mk_fpa_is_negative(Z3_context c, Z3_ast t);
|
||||
|
||||
/**
|
||||
\brief Predicate indicating whether t is a positive floating-point number.
|
||||
|
@ -666,7 +666,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_is_positive', AST, (_in(CONTEXT),_in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_is_positive(__in Z3_context c, __in Z3_ast t);
|
||||
Z3_ast Z3_API Z3_mk_fpa_is_positive(Z3_context c, Z3_ast t);
|
||||
|
||||
/**
|
||||
\brief Conversion of a single IEEE 754-2008 bit-vector into a floating-point number.
|
||||
|
@ -684,7 +684,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_to_fp_bv', AST, (_in(CONTEXT),_in(AST),_in(SORT)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_to_fp_bv(__in Z3_context c, __in Z3_ast bv, __in Z3_sort s);
|
||||
Z3_ast Z3_API Z3_mk_fpa_to_fp_bv(Z3_context c, Z3_ast bv, Z3_sort s);
|
||||
|
||||
/**
|
||||
\brief Conversion of a FloatingPoint term into another term of different FloatingPoint sort.
|
||||
|
@ -702,7 +702,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_to_fp_float', AST, (_in(CONTEXT),_in(AST),_in(AST),_in(SORT)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_to_fp_float(__in Z3_context c, __in Z3_ast rm, __in Z3_ast t, __in Z3_sort s);
|
||||
Z3_ast Z3_API Z3_mk_fpa_to_fp_float(Z3_context c, Z3_ast rm, Z3_ast t, Z3_sort s);
|
||||
|
||||
/**
|
||||
\brief Conversion of a term of real sort into a term of FloatingPoint sort.
|
||||
|
@ -720,7 +720,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_to_fp_real', AST, (_in(CONTEXT),_in(AST),_in(AST),_in(SORT)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_to_fp_real(__in Z3_context c, __in Z3_ast rm, __in Z3_ast t, __in Z3_sort s);
|
||||
Z3_ast Z3_API Z3_mk_fpa_to_fp_real(Z3_context c, Z3_ast rm, Z3_ast t, Z3_sort s);
|
||||
|
||||
/**
|
||||
\brief Conversion of a 2's complement signed bit-vector term into a term of FloatingPoint sort.
|
||||
|
@ -739,7 +739,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_to_fp_signed', AST, (_in(CONTEXT),_in(AST),_in(AST),_in(SORT)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_to_fp_signed(__in Z3_context c, __in Z3_ast rm, __in Z3_ast t, __in Z3_sort s);
|
||||
Z3_ast Z3_API Z3_mk_fpa_to_fp_signed(Z3_context c, Z3_ast rm, Z3_ast t, Z3_sort s);
|
||||
|
||||
/**
|
||||
\brief Conversion of a 2's complement unsigned bit-vector term into a term of FloatingPoint sort.
|
||||
|
@ -758,7 +758,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_to_fp_unsigned', AST, (_in(CONTEXT),_in(AST),_in(AST),_in(SORT)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_to_fp_unsigned(__in Z3_context c, __in Z3_ast rm, __in Z3_ast t, __in Z3_sort s);
|
||||
Z3_ast Z3_API Z3_mk_fpa_to_fp_unsigned(Z3_context c, Z3_ast rm, Z3_ast t, Z3_sort s);
|
||||
|
||||
/**
|
||||
\brief Conversion of a floating-point term into an unsigned bit-vector.
|
||||
|
@ -774,7 +774,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_to_ubv', AST, (_in(CONTEXT),_in(AST),_in(AST),_in(UINT)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_to_ubv(__in Z3_context c, __in Z3_ast rm, __in Z3_ast t, __in unsigned sz);
|
||||
Z3_ast Z3_API Z3_mk_fpa_to_ubv(Z3_context c, Z3_ast rm, Z3_ast t, unsigned sz);
|
||||
|
||||
/**
|
||||
\brief Conversion of a floating-point term into a signed bit-vector.
|
||||
|
@ -790,7 +790,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_to_sbv', AST, (_in(CONTEXT),_in(AST),_in(AST),_in(UINT)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_to_sbv(__in Z3_context c, __in Z3_ast rm, __in Z3_ast t, __in unsigned sz);
|
||||
Z3_ast Z3_API Z3_mk_fpa_to_sbv(Z3_context c, Z3_ast rm, Z3_ast t, unsigned sz);
|
||||
|
||||
/**
|
||||
\brief Conversion of a floating-point term into a real-numbered term.
|
||||
|
@ -804,7 +804,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_to_real', AST, (_in(CONTEXT),_in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_to_real(__in Z3_context c, __in Z3_ast t);
|
||||
Z3_ast Z3_API Z3_mk_fpa_to_real(Z3_context c, Z3_ast t);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -820,7 +820,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_fpa_get_ebits', UINT, (_in(CONTEXT),_in(SORT)))
|
||||
*/
|
||||
unsigned Z3_API Z3_fpa_get_ebits(__in Z3_context c, __in Z3_sort s);
|
||||
unsigned Z3_API Z3_fpa_get_ebits(Z3_context c, Z3_sort s);
|
||||
|
||||
/**
|
||||
\brief Retrieves the number of bits reserved for the significand in a FloatingPoint sort.
|
||||
|
@ -830,7 +830,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_fpa_get_sbits', UINT, (_in(CONTEXT),_in(SORT)))
|
||||
*/
|
||||
unsigned Z3_API Z3_fpa_get_sbits(__in Z3_context c, __in Z3_sort s);
|
||||
unsigned Z3_API Z3_fpa_get_sbits(Z3_context c, Z3_sort s);
|
||||
|
||||
/**
|
||||
\brief Retrieves the sign of a floating-point literal.
|
||||
|
@ -843,7 +843,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_fpa_get_numeral_sign', BOOL, (_in(CONTEXT), _in(AST), _out(INT)))
|
||||
*/
|
||||
Z3_bool Z3_API Z3_fpa_get_numeral_sign(__in Z3_context c, __in Z3_ast t, __out int * sgn);
|
||||
Z3_bool Z3_API Z3_fpa_get_numeral_sign(Z3_context c, Z3_ast t, int * sgn);
|
||||
|
||||
/**
|
||||
\brief Return the significand value of a floating-point numeral as a string.
|
||||
|
@ -856,7 +856,21 @@ extern "C" {
|
|||
|
||||
def_API('Z3_fpa_get_numeral_significand_string', STRING, (_in(CONTEXT), _in(AST)))
|
||||
*/
|
||||
Z3_string Z3_API Z3_fpa_get_numeral_significand_string(__in Z3_context c, __in Z3_ast t);
|
||||
Z3_string Z3_API Z3_fpa_get_numeral_significand_string(Z3_context c, Z3_ast t);
|
||||
|
||||
/**
|
||||
\brief Return the significand value of a floating-point numeral as a uint64.
|
||||
|
||||
\param c logical context
|
||||
\param t a floating-point numeral
|
||||
|
||||
Remarks: This function extracts the significand bits in `t`, without the
|
||||
hidden bit or normalization. Sets the Z3_INVALID_ARG error code if the
|
||||
significand does not fit into a uint64.
|
||||
|
||||
def_API('Z3_fpa_get_numeral_significand_uint64', BOOL, (_in(CONTEXT), _in(AST), _out(UINT64)))
|
||||
*/
|
||||
Z3_bool Z3_API Z3_fpa_get_numeral_significand_uint64(Z3_context c, Z3_ast t, __uint64 * n);
|
||||
|
||||
/**
|
||||
\brief Return the exponent value of a floating-point numeral as a string
|
||||
|
@ -866,7 +880,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_fpa_get_numeral_exponent_string', STRING, (_in(CONTEXT), _in(AST)))
|
||||
*/
|
||||
Z3_string Z3_API Z3_fpa_get_numeral_exponent_string(__in Z3_context c, __in Z3_ast t);
|
||||
Z3_string Z3_API Z3_fpa_get_numeral_exponent_string(Z3_context c, Z3_ast t);
|
||||
|
||||
/**
|
||||
\brief Return the exponent value of a floating-point numeral as a signed 64-bit integer
|
||||
|
@ -877,7 +891,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_fpa_get_numeral_exponent_int64', BOOL, (_in(CONTEXT), _in(AST), _out(INT64)))
|
||||
*/
|
||||
Z3_bool Z3_API Z3_fpa_get_numeral_exponent_int64(__in Z3_context c, __in Z3_ast t, __out __int64 * n);
|
||||
Z3_bool Z3_API Z3_fpa_get_numeral_exponent_int64(Z3_context c, Z3_ast t, __int64 * n);
|
||||
|
||||
/**
|
||||
\brief Conversion of a floating-point term into a bit-vector term in IEEE 754-2008 format.
|
||||
|
@ -894,7 +908,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_to_ieee_bv', AST, (_in(CONTEXT),_in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_to_ieee_bv(__in Z3_context c, __in Z3_ast t);
|
||||
Z3_ast Z3_API Z3_mk_fpa_to_ieee_bv(Z3_context c, Z3_ast t);
|
||||
|
||||
/**
|
||||
\brief Conversion of a real-sorted significand and an integer-sorted exponent into a term of FloatingPoint sort.
|
||||
|
@ -913,7 +927,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_fpa_to_fp_int_real', AST, (_in(CONTEXT),_in(AST),_in(AST),_in(AST),_in(SORT)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_fpa_to_fp_int_real(__in Z3_context c, __in Z3_ast rm, __in Z3_ast exp, __in Z3_ast sig, __in Z3_sort s);
|
||||
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);
|
||||
|
||||
/*@}*/
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@ Author:
|
|||
Notes:
|
||||
|
||||
--*/
|
||||
#ifndef _Z3_INTERPOLATION_H_
|
||||
#define _Z3_INTERPOLATION_H_
|
||||
#ifndef Z3_INTERPOLATION_H_
|
||||
#define Z3_INTERPOLATION_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -43,7 +43,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_mk_interpolant', AST, (_in(CONTEXT), _in(AST)))
|
||||
*/
|
||||
Z3_ast Z3_API Z3_mk_interpolant(__in Z3_context c, __in Z3_ast a);
|
||||
Z3_ast Z3_API Z3_mk_interpolant(Z3_context c, Z3_ast a);
|
||||
|
||||
|
||||
/** \brief This function generates a Z3 context suitable for generation of
|
||||
|
@ -62,7 +62,7 @@ extern "C" {
|
|||
|
||||
*/
|
||||
|
||||
Z3_context Z3_API Z3_mk_interpolation_context(__in Z3_config cfg);
|
||||
Z3_context Z3_API Z3_mk_interpolation_context(Z3_config cfg);
|
||||
|
||||
/** Compute an interpolant from a refutation. This takes a proof of
|
||||
"false" from a set of formulas C, and an interpolation
|
||||
|
@ -130,7 +130,7 @@ extern "C" {
|
|||
def_API('Z3_get_interpolant', AST_VECTOR, (_in(CONTEXT), _in(AST), _in(AST), _in(PARAMS)))
|
||||
*/
|
||||
|
||||
Z3_ast_vector Z3_API Z3_get_interpolant(__in Z3_context c, __in Z3_ast pf, __in Z3_ast pat, __in Z3_params p);
|
||||
Z3_ast_vector Z3_API Z3_get_interpolant(Z3_context c, Z3_ast pf, Z3_ast pat, Z3_params p);
|
||||
|
||||
/* Compute an interpolant for an unsatisfiable conjunction of formulas.
|
||||
|
||||
|
@ -164,11 +164,11 @@ extern "C" {
|
|||
def_API('Z3_compute_interpolant', INT, (_in(CONTEXT), _in(AST), _in(PARAMS), _out(AST_VECTOR), _out(MODEL)))
|
||||
*/
|
||||
|
||||
Z3_lbool Z3_API Z3_compute_interpolant(__in Z3_context c,
|
||||
__in Z3_ast pat,
|
||||
__in Z3_params p,
|
||||
__out Z3_ast_vector *interp,
|
||||
__out Z3_model *model);
|
||||
Z3_lbool Z3_API Z3_compute_interpolant(Z3_context c,
|
||||
Z3_ast pat,
|
||||
Z3_params p,
|
||||
Z3_ast_vector *interp,
|
||||
Z3_model *model);
|
||||
|
||||
/** Return a string summarizing cumulative time used for
|
||||
interpolation. This string is purely for entertainment purposes
|
||||
|
@ -180,7 +180,7 @@ extern "C" {
|
|||
def_API('Z3_interpolation_profile', STRING, (_in(CONTEXT),))
|
||||
*/
|
||||
|
||||
Z3_string Z3_API Z3_interpolation_profile(__in Z3_context ctx);
|
||||
Z3_string Z3_API Z3_interpolation_profile(Z3_context ctx);
|
||||
|
||||
/**
|
||||
\brief Read an interpolation problem from file.
|
||||
|
@ -219,14 +219,14 @@ extern "C" {
|
|||
|
||||
*/
|
||||
|
||||
int Z3_API Z3_read_interpolation_problem(__in Z3_context ctx,
|
||||
__out unsigned *num,
|
||||
__out Z3_ast *cnsts[],
|
||||
__out unsigned *parents[],
|
||||
__in Z3_string filename,
|
||||
__out_opt Z3_string_ptr error,
|
||||
__out unsigned *num_theory,
|
||||
__out Z3_ast *theory[]);
|
||||
int Z3_API Z3_read_interpolation_problem(Z3_context ctx,
|
||||
unsigned *num,
|
||||
Z3_ast *cnsts[],
|
||||
unsigned *parents[],
|
||||
Z3_string filename,
|
||||
Z3_string_ptr error,
|
||||
unsigned *num_theory,
|
||||
Z3_ast *theory[]);
|
||||
|
||||
|
||||
|
||||
|
@ -250,14 +250,14 @@ extern "C" {
|
|||
def_API('Z3_check_interpolant', INT, (_in(CONTEXT), _in(UINT), _in_array(1, AST), _in_array(1, UINT), _in_array(1, AST), _out(STRING), _in(UINT), _in_array(6, AST)))
|
||||
*/
|
||||
|
||||
int Z3_API Z3_check_interpolant(__in Z3_context ctx,
|
||||
__in unsigned num,
|
||||
__in_ecount(num) Z3_ast cnsts[],
|
||||
__in_ecount(num) unsigned parents[],
|
||||
__in_ecount(num - 1) Z3_ast *interps,
|
||||
__out_opt Z3_string_ptr error,
|
||||
__in unsigned num_theory,
|
||||
__in_ecount(num_theory) Z3_ast theory[]);
|
||||
int Z3_API Z3_check_interpolant(Z3_context ctx,
|
||||
unsigned num,
|
||||
Z3_ast cnsts[],
|
||||
unsigned parents[],
|
||||
Z3_ast *interps,
|
||||
Z3_string_ptr error,
|
||||
unsigned num_theory,
|
||||
Z3_ast theory[]);
|
||||
|
||||
/** Write an interpolation problem to file suitable for reading with
|
||||
Z3_read_interpolation_problem. The output file is a sequence
|
||||
|
@ -275,13 +275,13 @@ extern "C" {
|
|||
def_API('Z3_write_interpolation_problem', VOID, (_in(CONTEXT), _in(UINT), _in_array(1, AST), _in_array(1, UINT), _in(STRING), _in(UINT), _in_array(5, AST)))
|
||||
*/
|
||||
|
||||
void Z3_API Z3_write_interpolation_problem(__in Z3_context ctx,
|
||||
__in unsigned num,
|
||||
__in_ecount(num) Z3_ast cnsts[],
|
||||
__in_ecount(num) unsigned parents[],
|
||||
__in Z3_string filename,
|
||||
__in unsigned num_theory,
|
||||
__in_ecount(num_theory) Z3_ast theory[]);
|
||||
void Z3_API Z3_write_interpolation_problem(Z3_context ctx,
|
||||
unsigned num,
|
||||
Z3_ast cnsts[],
|
||||
unsigned parents[],
|
||||
Z3_string filename,
|
||||
unsigned num_theory,
|
||||
Z3_ast theory[]);
|
||||
|
||||
/*@}*/
|
||||
/*@}*/
|
||||
|
|
|
@ -1,34 +1,8 @@
|
|||
#ifndef __in
|
||||
#define __in
|
||||
#endif
|
||||
|
||||
#ifndef __out
|
||||
#define __out
|
||||
#endif
|
||||
/*++
|
||||
Copyright (c) 2015 Microsoft Corporation
|
||||
|
||||
#ifndef __out_opt
|
||||
#define __out_opt __out
|
||||
#endif
|
||||
|
||||
#ifndef __ecount
|
||||
#define __ecount(num_args)
|
||||
#endif
|
||||
|
||||
#ifndef __in_ecount
|
||||
#define __in_ecount(num_args) __in __ecount(num_args)
|
||||
#endif
|
||||
|
||||
#ifndef __out_ecount
|
||||
#define __out_ecount(num_args) __out __ecount(num_args)
|
||||
#endif
|
||||
|
||||
#ifndef __inout_ecount
|
||||
#define __inout_ecount(num_args) __in __out __ecount(num_args)
|
||||
#endif
|
||||
|
||||
#ifndef __inout
|
||||
#define __inout __in __out
|
||||
#endif
|
||||
--*/
|
||||
|
||||
#ifndef Z3_bool_opt
|
||||
#define Z3_bool_opt Z3_bool
|
||||
|
|
|
@ -17,8 +17,8 @@ Notes:
|
|||
|
||||
--*/
|
||||
|
||||
#ifndef _Z3_POLYNOMIAL_H_
|
||||
#define _Z3_POLYNOMIAL_H_
|
||||
#ifndef Z3_POLYNOMIAL_H_
|
||||
#define Z3_POLYNOMIAL_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -48,7 +48,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_polynomial_subresultants', AST_VECTOR, (_in(CONTEXT), _in(AST), _in(AST), _in(AST)))
|
||||
*/
|
||||
Z3_ast_vector Z3_API Z3_polynomial_subresultants(__in Z3_context c, __in Z3_ast p, __in Z3_ast q, __in Z3_ast x);
|
||||
Z3_ast_vector Z3_API Z3_polynomial_subresultants(Z3_context c, Z3_ast p, Z3_ast q, Z3_ast x);
|
||||
|
||||
|
||||
/*@}*/
|
||||
|
|
|
@ -22,8 +22,8 @@ Notes:
|
|||
#include"rational.h"
|
||||
#include"z3_macros.h"
|
||||
|
||||
#ifndef _Z3_PRIVATE__H_
|
||||
#define _Z3_PRIVATE__H_
|
||||
#ifndef Z3_PRIVATE_H_
|
||||
#define Z3_PRIVATE_H_
|
||||
|
||||
|
||||
#ifndef CAMLIDL
|
||||
|
@ -34,7 +34,7 @@ extern "C" {
|
|||
[pointer_default(ref)] interface Z3 {
|
||||
#endif // CAMLIDL
|
||||
|
||||
Z3_bool Z3_API Z3_get_numeral_rational(__in Z3_context c, __in Z3_ast a, rational& r);
|
||||
Z3_bool Z3_API Z3_get_numeral_rational(Z3_context c, Z3_ast a, rational& r);
|
||||
|
||||
#ifndef CAMLIDL
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -19,8 +19,8 @@ Author:
|
|||
Notes:
|
||||
|
||||
--*/
|
||||
#ifndef _Z3_RCF_H_
|
||||
#define _Z3_RCF_H_
|
||||
#ifndef Z3_RCF_H_
|
||||
#define Z3_RCF_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -43,42 +43,42 @@ extern "C" {
|
|||
|
||||
def_API('Z3_rcf_del', VOID, (_in(CONTEXT), _in(RCF_NUM)))
|
||||
*/
|
||||
void Z3_API Z3_rcf_del(__in Z3_context c, __in Z3_rcf_num a);
|
||||
void Z3_API Z3_rcf_del(Z3_context c, Z3_rcf_num a);
|
||||
|
||||
/**
|
||||
\brief Return a RCF rational using the given string.
|
||||
|
||||
def_API('Z3_rcf_mk_rational', RCF_NUM, (_in(CONTEXT), _in(STRING)))
|
||||
*/
|
||||
Z3_rcf_num Z3_API Z3_rcf_mk_rational(__in Z3_context c, __in Z3_string val);
|
||||
Z3_rcf_num Z3_API Z3_rcf_mk_rational(Z3_context c, Z3_string val);
|
||||
|
||||
/**
|
||||
\brief Return a RCF small integer.
|
||||
|
||||
def_API('Z3_rcf_mk_small_int', RCF_NUM, (_in(CONTEXT), _in(INT)))
|
||||
*/
|
||||
Z3_rcf_num Z3_API Z3_rcf_mk_small_int(__in Z3_context c, __in int val);
|
||||
Z3_rcf_num Z3_API Z3_rcf_mk_small_int(Z3_context c, int val);
|
||||
|
||||
/**
|
||||
\brief Return Pi
|
||||
|
||||
def_API('Z3_rcf_mk_pi', RCF_NUM, (_in(CONTEXT),))
|
||||
*/
|
||||
Z3_rcf_num Z3_API Z3_rcf_mk_pi(__in Z3_context c);
|
||||
Z3_rcf_num Z3_API Z3_rcf_mk_pi(Z3_context c);
|
||||
|
||||
/**
|
||||
\brief Return e (Euler's constant)
|
||||
|
||||
def_API('Z3_rcf_mk_e', RCF_NUM, (_in(CONTEXT),))
|
||||
*/
|
||||
Z3_rcf_num Z3_API Z3_rcf_mk_e(__in Z3_context c);
|
||||
Z3_rcf_num Z3_API Z3_rcf_mk_e(Z3_context c);
|
||||
|
||||
/**
|
||||
\brief Return a new infinitesimal that is smaller than all elements in the Z3 field.
|
||||
|
||||
def_API('Z3_rcf_mk_infinitesimal', RCF_NUM, (_in(CONTEXT),))
|
||||
*/
|
||||
Z3_rcf_num Z3_API Z3_rcf_mk_infinitesimal(__in Z3_context c);
|
||||
Z3_rcf_num Z3_API Z3_rcf_mk_infinitesimal(Z3_context c);
|
||||
|
||||
/**
|
||||
\brief Store in roots the roots of the polynomial <tt>a[n-1]*x^{n-1} + ... + a[0]</tt>.
|
||||
|
@ -89,112 +89,112 @@ extern "C" {
|
|||
|
||||
def_API('Z3_rcf_mk_roots', UINT, (_in(CONTEXT), _in(UINT), _in_array(1, RCF_NUM), _out_array(1, RCF_NUM)))
|
||||
*/
|
||||
unsigned Z3_API Z3_rcf_mk_roots(__in Z3_context c, __in unsigned n, __in_ecount(n) Z3_rcf_num const a[], __out_ecount(n) Z3_rcf_num roots[]);
|
||||
unsigned Z3_API Z3_rcf_mk_roots(Z3_context c, unsigned n, Z3_rcf_num const a[], Z3_rcf_num roots[]);
|
||||
|
||||
/**
|
||||
\brief Return the value a + b.
|
||||
|
||||
def_API('Z3_rcf_add', RCF_NUM, (_in(CONTEXT), _in(RCF_NUM), _in(RCF_NUM)))
|
||||
*/
|
||||
Z3_rcf_num Z3_API Z3_rcf_add(__in Z3_context c, __in Z3_rcf_num a, __in Z3_rcf_num b);
|
||||
Z3_rcf_num Z3_API Z3_rcf_add(Z3_context c, Z3_rcf_num a, Z3_rcf_num b);
|
||||
|
||||
/**
|
||||
\brief Return the value a - b.
|
||||
|
||||
def_API('Z3_rcf_sub', RCF_NUM, (_in(CONTEXT), _in(RCF_NUM), _in(RCF_NUM)))
|
||||
*/
|
||||
Z3_rcf_num Z3_API Z3_rcf_sub(__in Z3_context c, __in Z3_rcf_num a, __in Z3_rcf_num b);
|
||||
Z3_rcf_num Z3_API Z3_rcf_sub(Z3_context c, Z3_rcf_num a, Z3_rcf_num b);
|
||||
|
||||
/**
|
||||
\brief Return the value a * b.
|
||||
|
||||
def_API('Z3_rcf_mul', RCF_NUM, (_in(CONTEXT), _in(RCF_NUM), _in(RCF_NUM)))
|
||||
*/
|
||||
Z3_rcf_num Z3_API Z3_rcf_mul(__in Z3_context c, __in Z3_rcf_num a, __in Z3_rcf_num b);
|
||||
Z3_rcf_num Z3_API Z3_rcf_mul(Z3_context c, Z3_rcf_num a, Z3_rcf_num b);
|
||||
|
||||
/**
|
||||
\brief Return the value a / b.
|
||||
|
||||
def_API('Z3_rcf_div', RCF_NUM, (_in(CONTEXT), _in(RCF_NUM), _in(RCF_NUM)))
|
||||
*/
|
||||
Z3_rcf_num Z3_API Z3_rcf_div(__in Z3_context c, __in Z3_rcf_num a, __in Z3_rcf_num b);
|
||||
Z3_rcf_num Z3_API Z3_rcf_div(Z3_context c, Z3_rcf_num a, Z3_rcf_num b);
|
||||
|
||||
/**
|
||||
\brief Return the value -a
|
||||
|
||||
def_API('Z3_rcf_neg', RCF_NUM, (_in(CONTEXT), _in(RCF_NUM)))
|
||||
*/
|
||||
Z3_rcf_num Z3_API Z3_rcf_neg(__in Z3_context c, __in Z3_rcf_num a);
|
||||
Z3_rcf_num Z3_API Z3_rcf_neg(Z3_context c, Z3_rcf_num a);
|
||||
|
||||
/**
|
||||
\brief Return the value 1/a
|
||||
|
||||
def_API('Z3_rcf_inv', RCF_NUM, (_in(CONTEXT), _in(RCF_NUM)))
|
||||
*/
|
||||
Z3_rcf_num Z3_API Z3_rcf_inv(__in Z3_context c, __in Z3_rcf_num a);
|
||||
Z3_rcf_num Z3_API Z3_rcf_inv(Z3_context c, Z3_rcf_num a);
|
||||
|
||||
/**
|
||||
\brief Return the value a^k
|
||||
|
||||
def_API('Z3_rcf_power', RCF_NUM, (_in(CONTEXT), _in(RCF_NUM), _in(UINT)))
|
||||
*/
|
||||
Z3_rcf_num Z3_API Z3_rcf_power(__in Z3_context c, __in Z3_rcf_num a, __in unsigned k);
|
||||
Z3_rcf_num Z3_API Z3_rcf_power(Z3_context c, Z3_rcf_num a, unsigned k);
|
||||
|
||||
/**
|
||||
\brief Return Z3_TRUE if a < b
|
||||
|
||||
def_API('Z3_rcf_lt', BOOL, (_in(CONTEXT), _in(RCF_NUM), _in(RCF_NUM)))
|
||||
*/
|
||||
Z3_bool Z3_API Z3_rcf_lt(__in Z3_context c, __in Z3_rcf_num a, __in Z3_rcf_num b);
|
||||
Z3_bool Z3_API Z3_rcf_lt(Z3_context c, Z3_rcf_num a, Z3_rcf_num b);
|
||||
|
||||
/**
|
||||
\brief Return Z3_TRUE if a > b
|
||||
|
||||
def_API('Z3_rcf_gt', BOOL, (_in(CONTEXT), _in(RCF_NUM), _in(RCF_NUM)))
|
||||
*/
|
||||
Z3_bool Z3_API Z3_rcf_gt(__in Z3_context c, __in Z3_rcf_num a, __in Z3_rcf_num b);
|
||||
Z3_bool Z3_API Z3_rcf_gt(Z3_context c, Z3_rcf_num a, Z3_rcf_num b);
|
||||
|
||||
/**
|
||||
\brief Return Z3_TRUE if a <= b
|
||||
|
||||
def_API('Z3_rcf_le', BOOL, (_in(CONTEXT), _in(RCF_NUM), _in(RCF_NUM)))
|
||||
*/
|
||||
Z3_bool Z3_API Z3_rcf_le(__in Z3_context c, __in Z3_rcf_num a, __in Z3_rcf_num b);
|
||||
Z3_bool Z3_API Z3_rcf_le(Z3_context c, Z3_rcf_num a, Z3_rcf_num b);
|
||||
|
||||
/**
|
||||
\brief Return Z3_TRUE if a >= b
|
||||
|
||||
def_API('Z3_rcf_ge', BOOL, (_in(CONTEXT), _in(RCF_NUM), _in(RCF_NUM)))
|
||||
*/
|
||||
Z3_bool Z3_API Z3_rcf_ge(__in Z3_context c, __in Z3_rcf_num a, __in Z3_rcf_num b);
|
||||
Z3_bool Z3_API Z3_rcf_ge(Z3_context c, Z3_rcf_num a, Z3_rcf_num b);
|
||||
|
||||
/**
|
||||
\brief Return Z3_TRUE if a == b
|
||||
|
||||
def_API('Z3_rcf_eq', BOOL, (_in(CONTEXT), _in(RCF_NUM), _in(RCF_NUM)))
|
||||
*/
|
||||
Z3_bool Z3_API Z3_rcf_eq(__in Z3_context c, __in Z3_rcf_num a, __in Z3_rcf_num b);
|
||||
Z3_bool Z3_API Z3_rcf_eq(Z3_context c, Z3_rcf_num a, Z3_rcf_num b);
|
||||
|
||||
/**
|
||||
\brief Return Z3_TRUE if a != b
|
||||
|
||||
def_API('Z3_rcf_neq', BOOL, (_in(CONTEXT), _in(RCF_NUM), _in(RCF_NUM)))
|
||||
*/
|
||||
Z3_bool Z3_API Z3_rcf_neq(__in Z3_context c, __in Z3_rcf_num a, __in Z3_rcf_num b);
|
||||
Z3_bool Z3_API Z3_rcf_neq(Z3_context c, Z3_rcf_num a, Z3_rcf_num b);
|
||||
|
||||
/**
|
||||
\brief Convert the RCF numeral into a string.
|
||||
|
||||
def_API('Z3_rcf_num_to_string', STRING, (_in(CONTEXT), _in(RCF_NUM), _in(BOOL), _in(BOOL)))
|
||||
*/
|
||||
Z3_string Z3_API Z3_rcf_num_to_string(__in Z3_context c, __in Z3_rcf_num a, __in Z3_bool compact, __in Z3_bool html);
|
||||
Z3_string Z3_API Z3_rcf_num_to_string(Z3_context c, Z3_rcf_num a, Z3_bool compact, Z3_bool html);
|
||||
|
||||
/**
|
||||
\brief Convert the RCF numeral into a string in decimal notation.
|
||||
|
||||
def_API('Z3_rcf_num_to_decimal_string', STRING, (_in(CONTEXT), _in(RCF_NUM), _in(UINT)))
|
||||
*/
|
||||
Z3_string Z3_API Z3_rcf_num_to_decimal_string(__in Z3_context c, __in Z3_rcf_num a, __in unsigned prec);
|
||||
Z3_string Z3_API Z3_rcf_num_to_decimal_string(Z3_context c, Z3_rcf_num a, unsigned prec);
|
||||
|
||||
/**
|
||||
\brief Extract the "numerator" and "denominator" of the given RCF numeral.
|
||||
|
@ -202,7 +202,7 @@ extern "C" {
|
|||
|
||||
def_API('Z3_rcf_get_numerator_denominator', VOID, (_in(CONTEXT), _in(RCF_NUM), _out(RCF_NUM), _out(RCF_NUM)))
|
||||
*/
|
||||
void Z3_API Z3_rcf_get_numerator_denominator(__in Z3_context c, __in Z3_rcf_num a, __out Z3_rcf_num * n, __out Z3_rcf_num * d);
|
||||
void Z3_API Z3_rcf_get_numerator_denominator(Z3_context c, Z3_rcf_num a, Z3_rcf_num * n, Z3_rcf_num * d);
|
||||
|
||||
/*@}*/
|
||||
/*@}*/
|
||||
|
|
|
@ -22,12 +22,14 @@ Notes:
|
|||
#include"stream_buffer.h"
|
||||
#include"symbol.h"
|
||||
#include"trace.h"
|
||||
#include<sstream>
|
||||
|
||||
void register_z3_replayer_cmds(z3_replayer & in);
|
||||
|
||||
|
||||
void throw_invalid_reference() {
|
||||
TRACE("z3_replayer", tout << "invalid argument reference\n";);
|
||||
throw z3_replayer_exception("invalid argument reference");
|
||||
throw z3_replayer_exception("invalid argument reference1");
|
||||
}
|
||||
|
||||
struct z3_replayer::imp {
|
||||
|
@ -45,7 +47,38 @@ struct z3_replayer::imp {
|
|||
size_t_map<void *> m_heap;
|
||||
svector<z3_replayer_cmd> m_cmds;
|
||||
|
||||
enum value_kind { INT64, UINT64, DOUBLE, STRING, SYMBOL, OBJECT, UINT_ARRAY, SYMBOL_ARRAY, OBJECT_ARRAY, FLOAT };
|
||||
enum value_kind { INT64, UINT64, DOUBLE, STRING, SYMBOL, OBJECT, UINT_ARRAY, INT_ARRAY, SYMBOL_ARRAY, OBJECT_ARRAY, FLOAT };
|
||||
|
||||
char const* kind2string(value_kind k) const {
|
||||
switch (k) {
|
||||
case INT64: return "int64";
|
||||
case UINT64: return "uint64";
|
||||
case DOUBLE: return "double";
|
||||
case STRING: return "string";
|
||||
case SYMBOL: return "symbol";
|
||||
case OBJECT: return "object";
|
||||
case UINT_ARRAY: return "uint_array";
|
||||
case INT_ARRAY: return "int_array";
|
||||
case SYMBOL_ARRAY: return "symbol_array";
|
||||
case OBJECT_ARRAY: return "object_array";
|
||||
case FLOAT: return "float";
|
||||
default: UNREACHABLE(); return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void check_arg(unsigned pos, value_kind k) const {
|
||||
if (pos >= m_args.size()) {
|
||||
TRACE("z3_replayer", tout << "too few arguments " << m_args.size() << " expecting " << kind2string(k) << "\n";);
|
||||
throw z3_replayer_exception("invalid argument reference2");
|
||||
}
|
||||
if (m_args[pos].m_kind != k) {
|
||||
std::stringstream strm;
|
||||
strm << "expecting " << kind2string(k) << " at position "
|
||||
<< pos << " but got " << kind2string(m_args[pos].m_kind);
|
||||
throw z3_replayer_exception(strm.str().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
struct value {
|
||||
value_kind m_kind;
|
||||
|
@ -71,6 +104,7 @@ struct z3_replayer::imp {
|
|||
vector<ptr_vector<void> > m_obj_arrays;
|
||||
vector<svector<Z3_symbol> > m_sym_arrays;
|
||||
vector<unsigned_vector> m_unsigned_arrays;
|
||||
vector<svector<int> > m_int_arrays;
|
||||
|
||||
imp(z3_replayer & o, std::istream & in):
|
||||
m_owner(o),
|
||||
|
@ -321,6 +355,15 @@ struct z3_replayer::imp {
|
|||
v.push_back(static_cast<unsigned>(m_args[i].m_uint));
|
||||
}
|
||||
}
|
||||
if (k == INT64) {
|
||||
aidx = m_int_arrays.size();
|
||||
nk = INT_ARRAY;
|
||||
m_int_arrays.push_back(svector<int>());
|
||||
svector<int> & v = m_int_arrays.back();
|
||||
for (unsigned i = asz - sz; i < asz; i++) {
|
||||
v.push_back(static_cast<int>(m_args[i].m_int));
|
||||
}
|
||||
}
|
||||
else if (k == SYMBOL) {
|
||||
aidx = m_sym_arrays.size();
|
||||
nk = SYMBOL_ARRAY;
|
||||
|
@ -489,8 +532,7 @@ struct z3_replayer::imp {
|
|||
next(); skip_blank(); read_ptr(); skip_blank(); read_uint64();
|
||||
unsigned pos = static_cast<unsigned>(m_uint64);
|
||||
TRACE("z3_replayer", tout << "[" << m_line << "] " << "* " << m_ptr << " " << pos << "\n";);
|
||||
if (pos >= m_args.size() || m_args[pos].m_kind != OBJECT)
|
||||
throw_invalid_reference();
|
||||
check_arg(pos, OBJECT);
|
||||
m_heap.insert(m_ptr, m_args[pos].m_obj);
|
||||
break;
|
||||
}
|
||||
|
@ -499,8 +541,7 @@ struct z3_replayer::imp {
|
|||
// @ obj_id array_pos idx
|
||||
next(); skip_blank(); read_ptr(); skip_blank(); read_uint64();
|
||||
unsigned pos = static_cast<unsigned>(m_uint64);
|
||||
if (pos >= m_args.size() || m_args[pos].m_kind != OBJECT_ARRAY)
|
||||
throw_invalid_reference();
|
||||
check_arg(pos, OBJECT_ARRAY);
|
||||
unsigned aidx = static_cast<unsigned>(m_args[pos].m_uint);
|
||||
ptr_vector<void> & v = m_obj_arrays[aidx];
|
||||
skip_blank(); read_uint64();
|
||||
|
@ -525,26 +566,22 @@ struct z3_replayer::imp {
|
|||
}
|
||||
|
||||
int get_int(unsigned pos) const {
|
||||
if (pos >= m_args.size() || m_args[pos].m_kind != INT64)
|
||||
throw_invalid_reference();
|
||||
check_arg(pos, INT64);
|
||||
return static_cast<int>(m_args[pos].m_int);
|
||||
}
|
||||
|
||||
__int64 get_int64(unsigned pos) const {
|
||||
if (pos >= m_args.size() || m_args[pos].m_kind != INT64)
|
||||
throw_invalid_reference();
|
||||
check_arg(pos, INT64);
|
||||
return m_args[pos].m_int;
|
||||
}
|
||||
|
||||
unsigned get_uint(unsigned pos) const {
|
||||
if (pos >= m_args.size() || m_args[pos].m_kind != UINT64)
|
||||
throw_invalid_reference();
|
||||
check_arg(pos, UINT64);
|
||||
return static_cast<unsigned>(m_args[pos].m_uint);
|
||||
}
|
||||
|
||||
__uint64 get_uint64(unsigned pos) const {
|
||||
if (pos >= m_args.size() || m_args[pos].m_kind != UINT64)
|
||||
throw_invalid_reference();
|
||||
check_arg(pos, UINT64);
|
||||
return m_args[pos].m_uint;
|
||||
}
|
||||
|
||||
|
@ -555,46 +592,45 @@ struct z3_replayer::imp {
|
|||
}
|
||||
|
||||
double get_double(unsigned pos) const {
|
||||
if (pos >= m_args.size() || m_args[pos].m_kind != DOUBLE)
|
||||
throw_invalid_reference();
|
||||
check_arg(pos, DOUBLE);
|
||||
return m_args[pos].m_double;
|
||||
}
|
||||
|
||||
Z3_string get_str(unsigned pos) const {
|
||||
if (pos >= m_args.size() || m_args[pos].m_kind != STRING)
|
||||
throw_invalid_reference();
|
||||
check_arg(pos, STRING);
|
||||
return m_args[pos].m_str;
|
||||
}
|
||||
|
||||
Z3_symbol get_symbol(unsigned pos) const {
|
||||
if (pos >= m_args.size() || m_args[pos].m_kind != SYMBOL)
|
||||
throw_invalid_reference();
|
||||
check_arg(pos, SYMBOL);
|
||||
return reinterpret_cast<Z3_symbol>(const_cast<char*>(m_args[pos].m_str));
|
||||
}
|
||||
|
||||
void * get_obj(unsigned pos) const {
|
||||
if (pos >= m_args.size() || m_args[pos].m_kind != OBJECT)
|
||||
throw_invalid_reference();
|
||||
check_arg(pos, OBJECT);
|
||||
return m_args[pos].m_obj;
|
||||
}
|
||||
|
||||
unsigned * get_uint_array(unsigned pos) const {
|
||||
if (pos >= m_args.size() || m_args[pos].m_kind != UINT_ARRAY)
|
||||
throw_invalid_reference();
|
||||
check_arg(pos, UINT_ARRAY);
|
||||
unsigned idx = static_cast<unsigned>(m_args[pos].m_uint);
|
||||
return m_unsigned_arrays[idx].c_ptr();
|
||||
}
|
||||
|
||||
int * get_int_array(unsigned pos) const {
|
||||
check_arg(pos, INT_ARRAY);
|
||||
unsigned idx = static_cast<unsigned>(m_args[pos].m_uint);
|
||||
return m_int_arrays[idx].c_ptr();
|
||||
}
|
||||
|
||||
Z3_symbol * get_symbol_array(unsigned pos) const {
|
||||
if (pos >= m_args.size() || m_args[pos].m_kind != SYMBOL_ARRAY)
|
||||
throw_invalid_reference();
|
||||
check_arg(pos, SYMBOL_ARRAY);
|
||||
unsigned idx = static_cast<unsigned>(m_args[pos].m_uint);
|
||||
return m_sym_arrays[idx].c_ptr();
|
||||
}
|
||||
|
||||
void ** get_obj_array(unsigned pos) const {
|
||||
if (pos >= m_args.size() || m_args[pos].m_kind != OBJECT_ARRAY)
|
||||
throw_invalid_reference();
|
||||
check_arg(pos, OBJECT_ARRAY);
|
||||
unsigned idx = static_cast<unsigned>(m_args[pos].m_uint);
|
||||
ptr_vector<void> const & v = m_obj_arrays[idx];
|
||||
TRACE("z3_replayer_bug", tout << "pos: " << pos << ", idx: " << idx << " size(): " << v.size() << "\n";
|
||||
|
@ -603,38 +639,32 @@ struct z3_replayer::imp {
|
|||
}
|
||||
|
||||
int * get_int_addr(unsigned pos) {
|
||||
if (pos >= m_args.size() || m_args[pos].m_kind != INT64)
|
||||
throw_invalid_reference();
|
||||
check_arg(pos, INT64);
|
||||
return reinterpret_cast<int*>(&(m_args[pos].m_int));
|
||||
}
|
||||
|
||||
__int64 * get_int64_addr(unsigned pos) {
|
||||
if (pos >= m_args.size() || m_args[pos].m_kind != INT64)
|
||||
throw_invalid_reference();
|
||||
check_arg(pos, INT64);
|
||||
return &(m_args[pos].m_int);
|
||||
}
|
||||
|
||||
unsigned * get_uint_addr(unsigned pos) {
|
||||
if (pos >= m_args.size() || m_args[pos].m_kind != UINT64)
|
||||
throw_invalid_reference();
|
||||
check_arg(pos, UINT64);
|
||||
return reinterpret_cast<unsigned*>(&(m_args[pos].m_uint));
|
||||
}
|
||||
|
||||
__uint64 * get_uint64_addr(unsigned pos) {
|
||||
if (pos >= m_args.size() || m_args[pos].m_kind != UINT64)
|
||||
throw_invalid_reference();
|
||||
check_arg(pos, UINT64);
|
||||
return &(m_args[pos].m_uint);
|
||||
}
|
||||
|
||||
Z3_string * get_str_addr(unsigned pos) {
|
||||
if (pos >= m_args.size() || m_args[pos].m_kind != STRING)
|
||||
throw_invalid_reference();
|
||||
check_arg(pos, STRING);
|
||||
return &(m_args[pos].m_str);
|
||||
}
|
||||
|
||||
void ** get_obj_addr(unsigned pos) {
|
||||
if (pos >= m_args.size() || m_args[pos].m_kind != OBJECT)
|
||||
throw_invalid_reference();
|
||||
check_arg(pos, OBJECT);
|
||||
return &(m_args[pos].m_obj);
|
||||
}
|
||||
|
||||
|
@ -653,6 +683,7 @@ struct z3_replayer::imp {
|
|||
m_obj_arrays.reset();
|
||||
m_sym_arrays.reset();
|
||||
m_unsigned_arrays.reset();
|
||||
m_int_arrays.reset();
|
||||
}
|
||||
|
||||
|
||||
|
@ -715,6 +746,10 @@ unsigned * z3_replayer::get_uint_array(unsigned pos) const {
|
|||
return m_imp->get_uint_array(pos);
|
||||
}
|
||||
|
||||
int * z3_replayer::get_int_array(unsigned pos) const {
|
||||
return m_imp->get_int_array(pos);
|
||||
}
|
||||
|
||||
Z3_symbol * z3_replayer::get_symbol_array(unsigned pos) const {
|
||||
return m_imp->get_symbol_array(pos);
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@ Author:
|
|||
Notes:
|
||||
|
||||
--*/
|
||||
#ifndef _Z3_REPLAYER_H_
|
||||
#define _Z3_REPLAYER_H_
|
||||
#ifndef Z3_REPLAYER_H_
|
||||
#define Z3_REPLAYER_H_
|
||||
|
||||
#include<iostream>
|
||||
#include"z3.h"
|
||||
|
@ -50,6 +50,7 @@ public:
|
|||
void * get_obj(unsigned pos) const;
|
||||
|
||||
unsigned * get_uint_array(unsigned pos) const;
|
||||
int * get_int_array(unsigned pos) const;
|
||||
Z3_symbol * get_symbol_array(unsigned pos) const;
|
||||
void ** get_obj_array(unsigned pos) const;
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ Author:
|
|||
Notes:
|
||||
|
||||
--*/
|
||||
#ifndef _Z3_V1_H_
|
||||
#define _Z3_V1_H_
|
||||
#ifndef Z3_V1_H_
|
||||
#define Z3_V1_H_
|
||||
|
||||
#include"z3.h"
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@ Author:
|
|||
Notes:
|
||||
|
||||
--*/
|
||||
#ifndef _ACT_CACHE_H_
|
||||
#define _ACT_CACHE_H_
|
||||
#ifndef ACT_CACHE_H_
|
||||
#define ACT_CACHE_H_
|
||||
|
||||
#include"ast.h"
|
||||
#include"obj_hashtable.h"
|
||||
|
|
|
@ -16,8 +16,8 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef _ARITH_DECL_PLUGIN_H_
|
||||
#define _ARITH_DECL_PLUGIN_H_
|
||||
#ifndef ARITH_DECL_PLUGIN_H_
|
||||
#define ARITH_DECL_PLUGIN_H_
|
||||
|
||||
#include"ast.h"
|
||||
class sexpr;
|
||||
|
@ -399,5 +399,5 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
#endif /* _ARITH_DECL_PLUGIN_H_ */
|
||||
#endif /* ARITH_DECL_PLUGIN_H_ */
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef _ARRAY_DECL_PLUGIN_H_
|
||||
#define _ARRAY_DECL_PLUGIN_H_
|
||||
#ifndef ARRAY_DECL_PLUGIN_H_
|
||||
#define ARRAY_DECL_PLUGIN_H_
|
||||
|
||||
#include"ast.h"
|
||||
|
||||
|
@ -187,5 +187,5 @@ public:
|
|||
};
|
||||
|
||||
|
||||
#endif /* _ARRAY_DECL_PLUGIN_H_ */
|
||||
#endif /* ARRAY_DECL_PLUGIN_H_ */
|
||||
|
||||
|
|
194
src/ast/ast.cpp
194
src/ast/ast.cpp
|
@ -316,7 +316,8 @@ func_decl::func_decl(symbol const & name, unsigned arity, sort * const * domain,
|
|||
decl(AST_FUNC_DECL, name, info),
|
||||
m_arity(arity),
|
||||
m_range(range) {
|
||||
memcpy(const_cast<sort **>(get_domain()), domain, sizeof(sort *) * arity);
|
||||
if (arity != 0)
|
||||
memcpy(const_cast<sort **>(get_domain()), domain, sizeof(sort *) * arity);
|
||||
}
|
||||
|
||||
// -----------------------------------
|
||||
|
@ -378,8 +379,10 @@ quantifier::quantifier(bool forall, unsigned num_decls, sort * const * decl_sort
|
|||
|
||||
memcpy(const_cast<sort **>(get_decl_sorts()), decl_sorts, sizeof(sort *) * num_decls);
|
||||
memcpy(const_cast<symbol*>(get_decl_names()), decl_names, sizeof(symbol) * num_decls);
|
||||
memcpy(const_cast<expr **>(get_patterns()), patterns, sizeof(expr *) * num_patterns);
|
||||
memcpy(const_cast<expr **>(get_no_patterns()), no_patterns, sizeof(expr *) * num_no_patterns);
|
||||
if (num_patterns != 0)
|
||||
memcpy(const_cast<expr **>(get_patterns()), patterns, sizeof(expr *) * num_patterns);
|
||||
if (num_no_patterns != 0)
|
||||
memcpy(const_cast<expr **>(get_no_patterns()), no_patterns, sizeof(expr *) * num_no_patterns);
|
||||
}
|
||||
|
||||
// -----------------------------------
|
||||
|
@ -1013,17 +1016,43 @@ func_decl * basic_decl_plugin::mk_ite_decl(sort * s) {
|
|||
return m_ite_decls[id];
|
||||
}
|
||||
|
||||
sort* basic_decl_plugin::join(unsigned n, sort* const* srts) {
|
||||
SASSERT(n > 0);
|
||||
sort* s = srts[0];
|
||||
while (n > 1) {
|
||||
++srts;
|
||||
--n;
|
||||
s = join(s, *srts);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
sort* basic_decl_plugin::join(unsigned n, expr* const* es) {
|
||||
SASSERT(n > 0);
|
||||
sort* s = m_manager->get_sort(*es);
|
||||
while (n > 1) {
|
||||
++es;
|
||||
--n;
|
||||
s = join(s, m_manager->get_sort(*es));
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
sort* basic_decl_plugin::join(sort* s1, sort* s2) {
|
||||
if (s1 == s2) return s1;
|
||||
if (s1->get_family_id() == m_manager->m_arith_family_id &&
|
||||
if (s1->get_family_id() == m_manager->m_arith_family_id &&
|
||||
s2->get_family_id() == m_manager->m_arith_family_id) {
|
||||
if (s1->get_decl_kind() == REAL_SORT) {
|
||||
return s1;
|
||||
}
|
||||
return s2;
|
||||
}
|
||||
return s2;
|
||||
std::ostringstream buffer;
|
||||
buffer << "Sorts " << mk_pp(s1, *m_manager) << " and " << mk_pp(s2, *m_manager) << " are incompatible";
|
||||
throw ast_exception(buffer.str().c_str());
|
||||
}
|
||||
|
||||
|
||||
func_decl * basic_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters,
|
||||
unsigned arity, sort * const * domain, sort * range) {
|
||||
switch (static_cast<basic_op_kind>(k)) {
|
||||
|
@ -1038,8 +1067,8 @@ func_decl * basic_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters
|
|||
case OP_XOR: return m_xor_decl;
|
||||
case OP_ITE: return arity == 3 ? mk_ite_decl(join(domain[1], domain[2])) : 0;
|
||||
// eq and oeq must have at least two arguments, they can have more since they are chainable
|
||||
case OP_EQ: return arity >= 2 ? mk_eq_decl_core("=", OP_EQ, join(domain[0],domain[1]), m_eq_decls) : 0;
|
||||
case OP_OEQ: return arity >= 2 ? mk_eq_decl_core("~", OP_OEQ, join(domain[0],domain[1]), m_oeq_decls) : 0;
|
||||
case OP_EQ: return arity >= 2 ? mk_eq_decl_core("=", OP_EQ, join(arity, domain), m_eq_decls) : 0;
|
||||
case OP_OEQ: return arity >= 2 ? mk_eq_decl_core("~", OP_OEQ, join(arity, domain), m_oeq_decls) : 0;
|
||||
case OP_DISTINCT: {
|
||||
func_decl_info info(m_family_id, OP_DISTINCT);
|
||||
info.set_pairwise();
|
||||
|
@ -1081,10 +1110,8 @@ func_decl * basic_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters
|
|||
case OP_XOR: return m_xor_decl;
|
||||
case OP_ITE: return num_args == 3 ? mk_ite_decl(join(m_manager->get_sort(args[1]), m_manager->get_sort(args[2]))): 0;
|
||||
// eq and oeq must have at least two arguments, they can have more since they are chainable
|
||||
case OP_EQ: return num_args >= 2 ? mk_eq_decl_core("=", OP_EQ, join(m_manager->get_sort(args[0]),
|
||||
m_manager->get_sort(args[1])), m_eq_decls) : 0;
|
||||
case OP_OEQ: return num_args >= 2 ? mk_eq_decl_core("~", OP_OEQ, join(m_manager->get_sort(args[0]),
|
||||
m_manager->get_sort(args[1])), m_oeq_decls) : 0;
|
||||
case OP_EQ: return num_args >= 2 ? mk_eq_decl_core("=", OP_EQ, join(num_args, args), m_eq_decls) : 0;
|
||||
case OP_OEQ: return num_args >= 2 ? mk_eq_decl_core("~", OP_OEQ, join(num_args, args), m_oeq_decls) : 0;
|
||||
case OP_DISTINCT:
|
||||
return decl_plugin::mk_func_decl(k, num_parameters, parameters, num_args, args, range);
|
||||
default:
|
||||
|
@ -1975,75 +2002,114 @@ bool ast_manager::coercion_needed(func_decl * decl, unsigned num_args, expr * co
|
|||
}
|
||||
|
||||
app * ast_manager::mk_app_core(func_decl * decl, unsigned num_args, expr * const * args) {
|
||||
unsigned sz = app::get_obj_size(num_args);
|
||||
void * mem = allocate_node(sz);
|
||||
app * new_node;
|
||||
app * r;
|
||||
if (m_int_real_coercions && coercion_needed(decl, num_args, args)) {
|
||||
expr_ref_buffer new_args(*this);
|
||||
if (decl->is_associative()) {
|
||||
sort * d = decl->get_domain(0);
|
||||
for (unsigned i = 0; i < num_args; i++) {
|
||||
sort * s = get_sort(args[i]);
|
||||
if (d != s && d->get_family_id() == m_arith_family_id && s->get_family_id() == m_arith_family_id) {
|
||||
if (d->get_decl_kind() == REAL_SORT)
|
||||
new_args.push_back(mk_app(m_arith_family_id, OP_TO_REAL, args[i]));
|
||||
else
|
||||
new_args.push_back(mk_app(m_arith_family_id, OP_TO_INT, args[i]));
|
||||
}
|
||||
else {
|
||||
new_args.push_back(args[i]);
|
||||
app * r = 0;
|
||||
app * new_node = 0;
|
||||
unsigned sz = app::get_obj_size(num_args);
|
||||
void * mem = allocate_node(sz);
|
||||
|
||||
try {
|
||||
if (m_int_real_coercions && coercion_needed(decl, num_args, args)) {
|
||||
expr_ref_buffer new_args(*this);
|
||||
if (decl->is_associative()) {
|
||||
sort * d = decl->get_domain(0);
|
||||
for (unsigned i = 0; i < num_args; i++) {
|
||||
sort * s = get_sort(args[i]);
|
||||
if (d != s && d->get_family_id() == m_arith_family_id && s->get_family_id() == m_arith_family_id) {
|
||||
if (d->get_decl_kind() == REAL_SORT)
|
||||
new_args.push_back(mk_app(m_arith_family_id, OP_TO_REAL, args[i]));
|
||||
else
|
||||
new_args.push_back(mk_app(m_arith_family_id, OP_TO_INT, args[i]));
|
||||
}
|
||||
else {
|
||||
new_args.push_back(args[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (unsigned i = 0; i < num_args; i++) {
|
||||
sort * d = decl->get_domain(i);
|
||||
sort * s = get_sort(args[i]);
|
||||
if (d != s && d->get_family_id() == m_arith_family_id && s->get_family_id() == m_arith_family_id) {
|
||||
if (d->get_decl_kind() == REAL_SORT)
|
||||
new_args.push_back(mk_app(m_arith_family_id, OP_TO_REAL, args[i]));
|
||||
else
|
||||
new_args.push_back(mk_app(m_arith_family_id, OP_TO_INT, args[i]));
|
||||
}
|
||||
else {
|
||||
new_args.push_back(args[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
check_args(decl, num_args, new_args.c_ptr());
|
||||
SASSERT(new_args.size() == num_args);
|
||||
new_node = new (mem)app(decl, num_args, new_args.c_ptr());
|
||||
r = register_node(new_node);
|
||||
}
|
||||
else {
|
||||
for (unsigned i = 0; i < num_args; i++) {
|
||||
sort * d = decl->get_domain(i);
|
||||
sort * s = get_sort(args[i]);
|
||||
if (d != s && d->get_family_id() == m_arith_family_id && s->get_family_id() == m_arith_family_id) {
|
||||
if (d->get_decl_kind() == REAL_SORT)
|
||||
new_args.push_back(mk_app(m_arith_family_id, OP_TO_REAL, args[i]));
|
||||
else
|
||||
new_args.push_back(mk_app(m_arith_family_id, OP_TO_INT, args[i]));
|
||||
}
|
||||
else {
|
||||
new_args.push_back(args[i]);
|
||||
}
|
||||
check_args(decl, num_args, args);
|
||||
new_node = new (mem)app(decl, num_args, args);
|
||||
r = register_node(new_node);
|
||||
}
|
||||
|
||||
if (m_trace_stream && r == new_node) {
|
||||
*m_trace_stream << "[mk-app] #" << r->get_id() << " ";
|
||||
if (r->get_num_args() == 0 && r->get_decl()->get_name() == "int") {
|
||||
ast_ll_pp(*m_trace_stream, *this, r);
|
||||
}
|
||||
else if (is_label_lit(r)) {
|
||||
ast_ll_pp(*m_trace_stream, *this, r);
|
||||
}
|
||||
else {
|
||||
*m_trace_stream << r->get_decl()->get_name();
|
||||
for (unsigned i = 0; i < r->get_num_args(); i++)
|
||||
*m_trace_stream << " #" << r->get_arg(i)->get_id();
|
||||
*m_trace_stream << "\n";
|
||||
}
|
||||
}
|
||||
SASSERT(new_args.size() == num_args);
|
||||
new_node = new (mem) app(decl, num_args, new_args.c_ptr());
|
||||
r = register_node(new_node);
|
||||
}
|
||||
else {
|
||||
new_node = new (mem) app(decl, num_args, args);
|
||||
r = register_node(new_node);
|
||||
}
|
||||
|
||||
if (m_trace_stream && r == new_node) {
|
||||
*m_trace_stream << "[mk-app] #" << r->get_id() << " ";
|
||||
if (r->get_num_args() == 0 && r->get_decl()->get_name() == "int") {
|
||||
ast_ll_pp(*m_trace_stream, *this, r);
|
||||
} else if (is_label_lit(r)) {
|
||||
ast_ll_pp(*m_trace_stream, *this, r);
|
||||
} else {
|
||||
*m_trace_stream << r->get_decl()->get_name();
|
||||
for (unsigned i = 0; i < r->get_num_args(); i++)
|
||||
*m_trace_stream << " #" << r->get_arg(i)->get_id();
|
||||
*m_trace_stream << "\n";
|
||||
}
|
||||
catch (...) {
|
||||
deallocate_node(static_cast<ast*>(mem), sz);
|
||||
throw;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
void ast_manager::check_args(func_decl* f, unsigned n, expr* const* es) {
|
||||
for (unsigned i = 0; i < n; i++) {
|
||||
sort * actual_sort = get_sort(es[i]);
|
||||
sort * expected_sort = f->is_associative() ? f->get_domain(0) : f->get_domain(i);
|
||||
if (expected_sort != actual_sort) {
|
||||
std::ostringstream buffer;
|
||||
buffer << "Sort mismatch at argument #" << (i+1)
|
||||
<< " for function " << mk_pp(f,*this)
|
||||
<< " supplied sort is "
|
||||
<< mk_pp(actual_sort, *this);
|
||||
throw ast_exception(buffer.str().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline app * ast_manager::mk_app_core(func_decl * decl, expr * arg1, expr * arg2) {
|
||||
expr * args[2] = { arg1, arg2 };
|
||||
return mk_app_core(decl, 2, args);
|
||||
}
|
||||
|
||||
app * ast_manager::mk_app(func_decl * decl, unsigned num_args, expr * const * args) {
|
||||
SASSERT(decl->get_arity() == num_args || decl->is_right_associative() || decl->is_left_associative() || decl->is_chainable());
|
||||
bool type_error =
|
||||
decl->get_arity() != num_args && !decl->is_right_associative() &&
|
||||
!decl->is_left_associative() && !decl->is_chainable();
|
||||
|
||||
type_error |= (decl->get_arity() != num_args && num_args < 2 &&
|
||||
decl->get_family_id() == m_basic_family_id && !decl->is_associative());
|
||||
|
||||
if (type_error) {
|
||||
std::ostringstream buffer;
|
||||
buffer << "Wrong number of arguments (" << num_args
|
||||
<< ") passed to function " << mk_pp(decl, *this);
|
||||
throw ast_exception(buffer.str().c_str());
|
||||
}
|
||||
app * r = 0;
|
||||
if (num_args > 2 && !decl->is_flat_associative()) {
|
||||
if (decl->is_right_associative()) {
|
||||
|
@ -2078,6 +2144,8 @@ app * ast_manager::mk_app(func_decl * decl, unsigned num_args, expr * const * ar
|
|||
return r;
|
||||
}
|
||||
|
||||
|
||||
|
||||
func_decl * ast_manager::mk_fresh_func_decl(symbol const & prefix, symbol const & suffix, unsigned arity,
|
||||
sort * const * domain, sort * range) {
|
||||
func_decl_info info(null_family_id, null_decl_kind);
|
||||
|
@ -2574,6 +2642,8 @@ proof * ast_manager::mk_transitivity(proof * p1, proof * p2) {
|
|||
tout << mk_pp(to_app(get_fact(p1))->get_decl(), *this) << "\n";
|
||||
tout << mk_pp(to_app(get_fact(p2))->get_decl(), *this) << "\n";);
|
||||
SASSERT(to_app(get_fact(p1))->get_decl() == to_app(get_fact(p2))->get_decl() ||
|
||||
((is_iff(get_fact(p1)) || is_eq(get_fact(p1))) &&
|
||||
(is_iff(get_fact(p2)) || is_eq(get_fact(p2)))) ||
|
||||
( (is_eq(get_fact(p1)) || is_oeq(get_fact(p1))) &&
|
||||
(is_eq(get_fact(p2)) || is_oeq(get_fact(p2)))));
|
||||
CTRACE("mk_transitivity", to_app(get_fact(p1))->get_arg(1) != to_app(get_fact(p2))->get_arg(0),
|
||||
|
|
|
@ -16,8 +16,8 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef _AST_H_
|
||||
#define _AST_H_
|
||||
#ifndef AST_H_
|
||||
#define AST_H_
|
||||
|
||||
#include"vector.h"
|
||||
#include"hashtable.h"
|
||||
|
@ -44,6 +44,7 @@ Revision History:
|
|||
#include"chashtable.h"
|
||||
#include"z3_exception.h"
|
||||
#include"dependency.h"
|
||||
#include"rlimit.h"
|
||||
|
||||
#define RECYCLE_FREE_AST_INDICES
|
||||
|
||||
|
@ -1101,6 +1102,8 @@ protected:
|
|||
func_decl * mk_eq_decl_core(char const * name, decl_kind k, sort * s, ptr_vector<func_decl> & cache);
|
||||
func_decl * mk_ite_decl(sort * s);
|
||||
sort* join(sort* s1, sort* s2);
|
||||
sort* join(unsigned n, sort*const* srts);
|
||||
sort* join(unsigned n, expr*const* es);
|
||||
public:
|
||||
basic_decl_plugin();
|
||||
|
||||
|
@ -1422,6 +1425,7 @@ public:
|
|||
void show_id_gen();
|
||||
|
||||
protected:
|
||||
reslimit m_limit;
|
||||
small_object_allocator m_alloc;
|
||||
family_manager m_family_manager;
|
||||
expr_array_manager m_expr_array_manager;
|
||||
|
@ -1458,6 +1462,9 @@ protected:
|
|||
|
||||
bool coercion_needed(func_decl * decl, unsigned num_args, expr * const * args);
|
||||
|
||||
void check_args(func_decl* f, unsigned n, expr* const* es);
|
||||
|
||||
|
||||
public:
|
||||
ast_manager(proof_gen_mode = PGM_DISABLED, char const * trace_file = 0, bool is_format_manager = false);
|
||||
ast_manager(proof_gen_mode, std::fstream * trace_stream, bool is_format_manager = false);
|
||||
|
@ -1514,6 +1521,8 @@ public:
|
|||
fid == m_user_sort_family_id;
|
||||
}
|
||||
|
||||
reslimit& limit() { return m_limit; }
|
||||
|
||||
void register_plugin(symbol const & s, decl_plugin * plugin);
|
||||
|
||||
void register_plugin(family_id id, decl_plugin * plugin);
|
||||
|
@ -2006,6 +2015,7 @@ public:
|
|||
app * mk_false() { return m_false; }
|
||||
app * mk_interp(expr * arg) { return mk_app(m_basic_family_id, OP_INTERP, arg); }
|
||||
|
||||
|
||||
func_decl* mk_and_decl() {
|
||||
sort* domain[2] = { m_bool_sort, m_bool_sort };
|
||||
return mk_func_decl(m_basic_family_id, OP_AND, 0, 0, 2, domain);
|
||||
|
@ -2449,6 +2459,6 @@ public:
|
|||
void operator()(AST * n) { m_manager.inc_ref(n); }
|
||||
};
|
||||
|
||||
#endif /* _AST_H_ */
|
||||
#endif /* AST_H_ */
|
||||
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef _AST_LL_PP_H_
|
||||
#define _AST_LL_PP_H_
|
||||
#ifndef AST_LL_PP_H_
|
||||
#define AST_LL_PP_H_
|
||||
|
||||
#include"ast.h"
|
||||
#include<iostream>
|
||||
|
@ -53,5 +53,5 @@ inline std::ostream & operator<<(std::ostream & out, mk_bounded_pp const & p) {
|
|||
}
|
||||
|
||||
|
||||
#endif /* _AST_LL_PP_H_ */
|
||||
#endif /* AST_LL_PP_H_ */
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef _AST_LT_H_
|
||||
#define _AST_LT_H_
|
||||
#ifndef AST_LT_H_
|
||||
#define AST_LT_H_
|
||||
|
||||
class ast;
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ Revision History:
|
|||
2012-11-17 - ast_smt2_pp is the official pretty printer in Z3
|
||||
|
||||
--*/
|
||||
#ifndef _AST_PP_H_
|
||||
#define _AST_PP_H_
|
||||
#ifndef AST_PP_H_
|
||||
#define AST_PP_H_
|
||||
|
||||
#include"ast_smt2_pp.h"
|
||||
|
||||
|
|
69
src/ast/ast_pp_util.cpp
Normal file
69
src/ast/ast_pp_util.cpp
Normal file
|
@ -0,0 +1,69 @@
|
|||
/*++
|
||||
Copyright (c) 2015 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
ast_pp_util.cpp
|
||||
|
||||
Abstract:
|
||||
|
||||
<abstract>
|
||||
|
||||
Author:
|
||||
|
||||
Nikolaj Bjorner (nbjorner) 2015-8-6.
|
||||
|
||||
Revision History:
|
||||
|
||||
--*/
|
||||
|
||||
#include "ast_pp_util.h"
|
||||
#include "ast_smt2_pp.h"
|
||||
#include "ast_smt_pp.h"
|
||||
|
||||
void ast_pp_util::collect(expr* e) {
|
||||
coll.visit(e);
|
||||
}
|
||||
|
||||
void ast_pp_util::collect(unsigned n, expr* const* es) {
|
||||
for (unsigned i = 0; i < n; ++i) {
|
||||
coll.visit(es[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void ast_pp_util::collect(expr_ref_vector const& es) {
|
||||
collect(es.size(), es.c_ptr());
|
||||
}
|
||||
|
||||
void ast_pp_util::display_decls(std::ostream& out) {
|
||||
smt2_pp_environment_dbg env(m);
|
||||
ast_smt_pp pp(m);
|
||||
unsigned n = coll.get_num_sorts();
|
||||
for (unsigned i = 0; i < n; ++i) {
|
||||
pp.display_ast_smt2(out, coll.get_sorts()[i], 0, 0, 0);
|
||||
}
|
||||
n = coll.get_num_decls();
|
||||
for (unsigned i = 0; i < n; ++i) {
|
||||
ast_smt2_pp(out, coll.get_func_decls()[i], env);
|
||||
out << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
void ast_pp_util::display_asserts(std::ostream& out, expr_ref_vector const& fmls, bool neat) {
|
||||
if (neat) {
|
||||
smt2_pp_environment_dbg env(m);
|
||||
for (unsigned i = 0; i < fmls.size(); ++i) {
|
||||
out << "(assert ";
|
||||
ast_smt2_pp(out, fmls[i], env);
|
||||
out << ")\n";
|
||||
}
|
||||
}
|
||||
else {
|
||||
ast_smt_pp ll_smt2_pp(m);
|
||||
for (unsigned i = 0; i < fmls.size(); ++i) {
|
||||
out << "(assert ";
|
||||
ll_smt2_pp.display_expr_smt2(out, fmls[i]);
|
||||
out << ")\n";
|
||||
}
|
||||
}
|
||||
}
|
43
src/ast/ast_pp_util.h
Normal file
43
src/ast/ast_pp_util.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*++
|
||||
Copyright (c) 2015 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
ast_pp_util.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Utilities for printing SMT2 declarations and assertions.
|
||||
|
||||
Author:
|
||||
|
||||
Nikolaj Bjorner (nbjorner) 2015-8-6.
|
||||
|
||||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef AST_PP_UTIL_H_
|
||||
#define AST_PP_UTIL_H_
|
||||
|
||||
#include "decl_collector.h"
|
||||
|
||||
class ast_pp_util {
|
||||
ast_manager& m;
|
||||
public:
|
||||
|
||||
decl_collector coll;
|
||||
|
||||
ast_pp_util(ast_manager& m): m(m), coll(m, false) {}
|
||||
|
||||
void collect(expr* e);
|
||||
|
||||
void collect(unsigned n, expr* const* es);
|
||||
|
||||
void collect(expr_ref_vector const& es);
|
||||
|
||||
void display_decls(std::ostream& out);
|
||||
|
||||
void display_asserts(std::ostream& out, expr_ref_vector const& fmls, bool neat = true);
|
||||
};
|
||||
|
||||
#endif /* AST_PP_UTIL_H_ */
|
|
@ -16,8 +16,8 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef _AST_PRINTER_H_
|
||||
#define _AST_PRINTER_H_
|
||||
#ifndef AST_PRINTER_H_
|
||||
#define AST_PRINTER_H_
|
||||
|
||||
#include"ast.h"
|
||||
#include"ast_smt2_pp.h"
|
||||
|
|
|
@ -77,6 +77,8 @@ bool smt2_pp_environment::is_indexed_fdecl(func_decl * f) const {
|
|||
for (i = 0; i < num; i++) {
|
||||
if (f->get_parameter(i).is_int())
|
||||
continue;
|
||||
if (f->get_parameter(i).is_rational())
|
||||
continue;
|
||||
if (f->get_parameter(i).is_ast() && is_func_decl(f->get_parameter(i).get_ast()))
|
||||
continue;
|
||||
break;
|
||||
|
@ -105,9 +107,13 @@ format * smt2_pp_environment::pp_fdecl_params(format * fname, func_decl * f) {
|
|||
ptr_buffer<format> fs;
|
||||
fs.push_back(fname);
|
||||
for (unsigned i = 0; i < num; i++) {
|
||||
SASSERT(f->get_parameter(i).is_int() || (f->get_parameter(i).is_ast() && is_func_decl(f->get_parameter(i).get_ast())));
|
||||
SASSERT(f->get_parameter(i).is_int() ||
|
||||
f->get_parameter(i).is_rational() ||
|
||||
(f->get_parameter(i).is_ast() && is_func_decl(f->get_parameter(i).get_ast())));
|
||||
if (f->get_parameter(i).is_int())
|
||||
fs.push_back(mk_int(get_manager(), f->get_parameter(i).get_int()));
|
||||
else if (f->get_parameter(i).is_rational())
|
||||
fs.push_back(mk_string(get_manager(), f->get_parameter(i).get_rational().to_string().c_str()));
|
||||
else
|
||||
fs.push_back(pp_fdecl_ref(to_func_decl(f->get_parameter(i).get_ast())));
|
||||
}
|
||||
|
@ -335,22 +341,22 @@ format * smt2_pp_environment::pp_arith_literal(app * t, bool decimal, unsigned d
|
|||
}
|
||||
else {
|
||||
SASSERT(u.is_irrational_algebraic_numeral(t));
|
||||
anum const & val = u.to_irrational_algebraic_numeral(t);
|
||||
anum const & val2 = u.to_irrational_algebraic_numeral(t);
|
||||
algebraic_numbers::manager & am = u.am();
|
||||
format * vf;
|
||||
std::ostringstream buffer;
|
||||
bool is_neg = false;
|
||||
if (decimal) {
|
||||
scoped_anum abs_val(am);
|
||||
am.set(abs_val, val);
|
||||
if (am.is_neg(val)) {
|
||||
am.set(abs_val, val2);
|
||||
if (am.is_neg(val2)) {
|
||||
is_neg = true;
|
||||
am.neg(abs_val);
|
||||
}
|
||||
am.display_decimal(buffer, abs_val, decimal_prec);
|
||||
}
|
||||
else {
|
||||
am.display_root_smt2(buffer, val);
|
||||
am.display_root_smt2(buffer, val2);
|
||||
}
|
||||
vf = mk_string(get_manager(), buffer.str().c_str());
|
||||
return is_neg ? mk_neg(vf) : vf;
|
||||
|
@ -1159,6 +1165,26 @@ std::ostream& operator<<(std::ostream& out, mk_ismt2_pp const & p) {
|
|||
return out;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, expr_ref const& e) {
|
||||
return out << mk_ismt2_pp(e.get(), e.get_manager());
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, app_ref const& e) {
|
||||
return out << mk_ismt2_pp(e.get(), e.get_manager());
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, expr_ref_vector const& e) {
|
||||
for (unsigned i = 0; i < e.size(); ++i)
|
||||
out << mk_ismt2_pp(e[i], e.get_manager()) << "\n";
|
||||
return out;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, app_ref_vector const& e) {
|
||||
for (unsigned i = 0; i < e.size(); ++i)
|
||||
out << mk_ismt2_pp(e[i], e.get_manager()) << "\n";
|
||||
return out;
|
||||
}
|
||||
|
||||
#ifdef Z3DEBUG
|
||||
void pp(expr const * n, ast_manager & m) {
|
||||
std::cout << mk_ismt2_pp(const_cast<expr*>(n), m) << std::endl;
|
||||
|
|
|
@ -19,8 +19,8 @@ Revision History:
|
|||
|
||||
|
||||
--*/
|
||||
#ifndef _AST_SMT2_PP_H_
|
||||
#define _AST_SMT2_PP_H_
|
||||
#ifndef AST_SMT2_PP_H_
|
||||
#define AST_SMT2_PP_H_
|
||||
|
||||
#include"format.h"
|
||||
#include"params.h"
|
||||
|
@ -110,4 +110,10 @@ struct mk_ismt2_pp {
|
|||
|
||||
std::ostream& operator<<(std::ostream& out, mk_ismt2_pp const & p);
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, expr_ref const& e);
|
||||
std::ostream& operator<<(std::ostream& out, app_ref const& e);
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, expr_ref_vector const& e);
|
||||
std::ostream& operator<<(std::ostream& out, app_ref_vector const& e);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -913,9 +913,9 @@ public:
|
|||
m_out << "(";
|
||||
}
|
||||
m_out << m_renaming.get_symbol(f->get_name());
|
||||
// if (accs.size() > 0) {
|
||||
if (!accs.empty() || !m_is_smt2) {
|
||||
m_out << " ";
|
||||
// }
|
||||
}
|
||||
for (unsigned j = 0; j < accs.size(); ++j) {
|
||||
func_decl* a = accs[j];
|
||||
m_out << "(" << m_renaming.get_symbol(a->get_name()) << " ";
|
||||
|
@ -1058,7 +1058,8 @@ void ast_smt_pp::display_ast_smt2(std::ostream& strm, ast* a, unsigned indent, u
|
|||
|
||||
void ast_smt_pp::display_smt2(std::ostream& strm, expr* n) {
|
||||
ptr_vector<quantifier> ql;
|
||||
decl_collector decls(m_manager);
|
||||
ast_manager& m = m_manager;
|
||||
decl_collector decls(m);
|
||||
smt_renaming rn;
|
||||
|
||||
for (unsigned i = 0; i < m_assumptions.size(); ++i) {
|
||||
|
@ -1069,7 +1070,7 @@ void ast_smt_pp::display_smt2(std::ostream& strm, expr* n) {
|
|||
}
|
||||
decls.visit(n);
|
||||
|
||||
if (m_manager.is_proof(n)) {
|
||||
if (m.is_proof(n)) {
|
||||
strm << "(";
|
||||
}
|
||||
if (m_benchmark_name != symbol::null) {
|
||||
|
@ -1078,7 +1079,7 @@ void ast_smt_pp::display_smt2(std::ostream& strm, expr* n) {
|
|||
if (m_source_info != symbol::null && m_source_info != symbol("")) {
|
||||
strm << "; :source { " << m_source_info << " }\n";
|
||||
}
|
||||
if (m_manager.is_bool(n)) {
|
||||
if (m.is_bool(n)) {
|
||||
strm << "(set-info :status " << m_status << ")\n";
|
||||
}
|
||||
if (m_category != symbol::null && m_category != symbol("")) {
|
||||
|
@ -1095,7 +1096,7 @@ void ast_smt_pp::display_smt2(std::ostream& strm, expr* n) {
|
|||
for (unsigned i = 0; i < decls.get_num_sorts(); ++i) {
|
||||
sort* s = decls.get_sorts()[i];
|
||||
if (!(*m_is_declared)(s)) {
|
||||
smt_printer p(strm, m_manager, ql, rn, m_logic, true, true, m_simplify_implies, 0);
|
||||
smt_printer p(strm, m, ql, rn, m_logic, true, true, m_simplify_implies, 0);
|
||||
p.pp_sort_decl(sort_mark, s);
|
||||
}
|
||||
}
|
||||
|
@ -1103,7 +1104,7 @@ void ast_smt_pp::display_smt2(std::ostream& strm, expr* n) {
|
|||
for (unsigned i = 0; i < decls.get_num_decls(); ++i) {
|
||||
func_decl* d = decls.get_func_decls()[i];
|
||||
if (!(*m_is_declared)(d)) {
|
||||
smt_printer p(strm, m_manager, ql, rn, m_logic, true, true, m_simplify_implies, 0);
|
||||
smt_printer p(strm, m, ql, rn, m_logic, true, true, m_simplify_implies, 0);
|
||||
p(d);
|
||||
strm << "\n";
|
||||
}
|
||||
|
@ -1112,34 +1113,36 @@ void ast_smt_pp::display_smt2(std::ostream& strm, expr* n) {
|
|||
for (unsigned i = 0; i < decls.get_num_preds(); ++i) {
|
||||
func_decl* d = decls.get_pred_decls()[i];
|
||||
if (!(*m_is_declared)(d)) {
|
||||
smt_printer p(strm, m_manager, ql, rn, m_logic, true, true, m_simplify_implies, 0);
|
||||
smt_printer p(strm, m, ql, rn, m_logic, true, true, m_simplify_implies, 0);
|
||||
p(d);
|
||||
strm << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < m_assumptions.size(); ++i) {
|
||||
strm << "(assert\n";
|
||||
smt_printer p(strm, m_manager, ql, rn, m_logic, false, true, m_simplify_implies, 0);
|
||||
p(m_assumptions[i].get());
|
||||
strm << ")\n";
|
||||
smt_printer p(strm, m, ql, rn, m_logic, false, true, m_simplify_implies, 1);
|
||||
strm << "(assert\n ";
|
||||
p(m_assumptions[i].get());
|
||||
strm << ")\n";
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < m_assumptions_star.size(); ++i) {
|
||||
strm << "(assert\n";
|
||||
smt_printer p(strm, m_manager, ql, rn, m_logic, false, true, m_simplify_implies, 0);
|
||||
p(m_assumptions_star[i].get());
|
||||
smt_printer p(strm, m, ql, rn, m_logic, false, true, m_simplify_implies, 1);
|
||||
strm << "(assert\n ";
|
||||
p(m_assumptions_star[i].get());
|
||||
strm << ")\n";
|
||||
}
|
||||
|
||||
smt_printer p(strm, m_manager, ql, rn, m_logic, false, true, m_simplify_implies, 0);
|
||||
if (m_manager.is_bool(n)) {
|
||||
strm << "(assert\n";
|
||||
p(n);
|
||||
strm << ")\n";
|
||||
smt_printer p(strm, m, ql, rn, m_logic, false, true, m_simplify_implies, 0);
|
||||
if (m.is_bool(n)) {
|
||||
if (!m.is_true(n)) {
|
||||
strm << "(assert\n ";
|
||||
p(n);
|
||||
strm << ")\n";
|
||||
}
|
||||
strm << "(check-sat)\n";
|
||||
}
|
||||
else if (m_manager.is_proof(n)) {
|
||||
else if (m.is_proof(n)) {
|
||||
strm << "(proof\n";
|
||||
p(n);
|
||||
strm << "))\n";
|
||||
|
|
|
@ -16,8 +16,8 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef _AST_SMT_PP_H_
|
||||
#define _AST_SMT_PP_H_
|
||||
#ifndef AST_SMT_PP_H_
|
||||
#define AST_SMT_PP_H_
|
||||
|
||||
#include"ast.h"
|
||||
#include<string>
|
||||
|
|
76
src/ast/ast_trail.h
Normal file
76
src/ast/ast_trail.h
Normal file
|
@ -0,0 +1,76 @@
|
|||
/*++
|
||||
Copyright (c) 2006 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
ast_trail.h
|
||||
|
||||
Abstract:
|
||||
|
||||
<abstract>
|
||||
|
||||
Author:
|
||||
|
||||
Leonardo de Moura (leonardo) 2008-06-02.
|
||||
|
||||
Revision History:
|
||||
|
||||
Extracted AST specific features from trail.h
|
||||
nbjorner 2014-9-28
|
||||
|
||||
--*/
|
||||
#ifndef AST_TRAIL_H_
|
||||
#define AST_TRAIL_H_
|
||||
|
||||
#include"ast.h"
|
||||
#include"trail.h"
|
||||
|
||||
|
||||
template<typename S, typename T>
|
||||
class ast2ast_trailmap {
|
||||
ref_vector<S, ast_manager> m_domain;
|
||||
ref_vector<T, ast_manager> m_range;
|
||||
obj_map<S, T*> m_map;
|
||||
public:
|
||||
ast2ast_trailmap(ast_manager& m):
|
||||
m_domain(m),
|
||||
m_range(m),
|
||||
m_map()
|
||||
{}
|
||||
|
||||
bool find(S* s, T*& t) {
|
||||
return m_map.find(s,t);
|
||||
}
|
||||
|
||||
void insert(S* s, T* t) {
|
||||
SASSERT(!m_map.contains(s));
|
||||
m_domain.push_back(s);
|
||||
m_range.push_back(t);
|
||||
m_map.insert(s,t);
|
||||
}
|
||||
|
||||
void pop() {
|
||||
SASSERT(!m_domain.empty());
|
||||
m_map.remove(m_domain.back());
|
||||
m_domain.pop_back();
|
||||
m_range.pop_back();
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Ctx, typename S, typename T>
|
||||
class ast2ast_trail : public trail<Ctx> {
|
||||
ast2ast_trailmap<S,T>& m_map;
|
||||
public:
|
||||
ast2ast_trail(ast2ast_trailmap<S,T>& m, S* s, T* t) :
|
||||
m_map(m) {
|
||||
m.insert(s,t);
|
||||
}
|
||||
|
||||
virtual void undo(Ctx& ctx) {
|
||||
m_map.pop();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif /* AST_TRAIL_H_ */
|
||||
|
|
@ -18,8 +18,8 @@ Revision History:
|
|||
2011-05-26: New local translation class.
|
||||
|
||||
--*/
|
||||
#ifndef _AST_TRANSLATION_H_
|
||||
#define _AST_TRANSLATION_H_
|
||||
#ifndef AST_TRANSLATION_H_
|
||||
#define AST_TRANSLATION_H_
|
||||
|
||||
#include"ast.h"
|
||||
|
||||
|
|
|
@ -44,12 +44,12 @@ app * mk_list_assoc_app(ast_manager & m, family_id fid, decl_kind k, unsigned nu
|
|||
return mk_list_assoc_app(m, decl, num_args, args);
|
||||
}
|
||||
|
||||
bool is_well_formed_vars(ptr_vector<sort>& bound, expr* e) {
|
||||
bool is_well_formed_vars(ptr_vector<sort>& bound, expr * top) {
|
||||
ptr_vector<expr> todo;
|
||||
ast_mark mark;
|
||||
todo.push_back(e);
|
||||
todo.push_back(top);
|
||||
while (!todo.empty()) {
|
||||
expr* e = todo.back();
|
||||
expr * e = todo.back();
|
||||
todo.pop_back();
|
||||
if (mark.is_marked(e)) {
|
||||
continue;
|
||||
|
@ -191,3 +191,116 @@ expr * expand_distinct(ast_manager & m, unsigned num_args, expr * const * args)
|
|||
}
|
||||
return mk_and(m, new_diseqs.size(), new_diseqs.c_ptr());
|
||||
}
|
||||
|
||||
void flatten_and(expr_ref_vector& result) {
|
||||
ast_manager& m = result.get_manager();
|
||||
expr* e1, *e2, *e3;
|
||||
for (unsigned i = 0; i < result.size(); ++i) {
|
||||
if (m.is_and(result[i].get())) {
|
||||
app* a = to_app(result[i].get());
|
||||
unsigned num_args = a->get_num_args();
|
||||
for (unsigned j = 0; j < num_args; ++j) {
|
||||
result.push_back(a->get_arg(j));
|
||||
}
|
||||
result[i] = result.back();
|
||||
result.pop_back();
|
||||
--i;
|
||||
}
|
||||
else if (m.is_not(result[i].get(), e1) && m.is_not(e1, e2)) {
|
||||
result[i] = e2;
|
||||
--i;
|
||||
}
|
||||
else if (m.is_not(result[i].get(), e1) && m.is_or(e1)) {
|
||||
app* a = to_app(e1);
|
||||
unsigned num_args = a->get_num_args();
|
||||
for (unsigned j = 0; j < num_args; ++j) {
|
||||
result.push_back(m.mk_not(a->get_arg(j)));
|
||||
}
|
||||
result[i] = result.back();
|
||||
result.pop_back();
|
||||
--i;
|
||||
}
|
||||
else if (m.is_not(result[i].get(), e1) && m.is_implies(e1,e2,e3)) {
|
||||
result.push_back(e2);
|
||||
result[i] = m.mk_not(e3);
|
||||
--i;
|
||||
}
|
||||
else if (m.is_true(result[i].get()) ||
|
||||
(m.is_not(result[i].get(), e1) &&
|
||||
m.is_false(e1))) {
|
||||
result[i] = result.back();
|
||||
result.pop_back();
|
||||
--i;
|
||||
}
|
||||
else if (m.is_false(result[i].get()) ||
|
||||
(m.is_not(result[i].get(), e1) &&
|
||||
m.is_true(e1))) {
|
||||
result.reset();
|
||||
result.push_back(m.mk_false());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void flatten_and(expr* fml, expr_ref_vector& result) {
|
||||
SASSERT(result.get_manager().is_bool(fml));
|
||||
result.push_back(fml);
|
||||
flatten_and(result);
|
||||
}
|
||||
|
||||
void flatten_or(expr_ref_vector& result) {
|
||||
ast_manager& m = result.get_manager();
|
||||
expr* e1, *e2, *e3;
|
||||
for (unsigned i = 0; i < result.size(); ++i) {
|
||||
if (m.is_or(result[i].get())) {
|
||||
app* a = to_app(result[i].get());
|
||||
unsigned num_args = a->get_num_args();
|
||||
for (unsigned j = 0; j < num_args; ++j) {
|
||||
result.push_back(a->get_arg(j));
|
||||
}
|
||||
result[i] = result.back();
|
||||
result.pop_back();
|
||||
--i;
|
||||
}
|
||||
else if (m.is_not(result[i].get(), e1) && m.is_not(e1, e2)) {
|
||||
result[i] = e2;
|
||||
--i;
|
||||
}
|
||||
else if (m.is_not(result[i].get(), e1) && m.is_and(e1)) {
|
||||
app* a = to_app(e1);
|
||||
unsigned num_args = a->get_num_args();
|
||||
for (unsigned j = 0; j < num_args; ++j) {
|
||||
result.push_back(m.mk_not(a->get_arg(j)));
|
||||
}
|
||||
result[i] = result.back();
|
||||
result.pop_back();
|
||||
--i;
|
||||
}
|
||||
else if (m.is_implies(result[i].get(),e2,e3)) {
|
||||
result.push_back(e3);
|
||||
result[i] = m.mk_not(e2);
|
||||
--i;
|
||||
}
|
||||
else if (m.is_false(result[i].get()) ||
|
||||
(m.is_not(result[i].get(), e1) &&
|
||||
m.is_true(e1))) {
|
||||
result[i] = result.back();
|
||||
result.pop_back();
|
||||
--i;
|
||||
}
|
||||
else if (m.is_true(result[i].get()) ||
|
||||
(m.is_not(result[i].get(), e1) &&
|
||||
m.is_false(e1))) {
|
||||
result.reset();
|
||||
result.push_back(m.mk_true());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void flatten_or(expr* fml, expr_ref_vector& result) {
|
||||
SASSERT(result.get_manager().is_bool(fml));
|
||||
result.push_back(fml);
|
||||
flatten_or(result);
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef _AST_UTIL_H_
|
||||
#define _AST_UTIL_H_
|
||||
#ifndef AST_UTIL_H_
|
||||
#define AST_UTIL_H_
|
||||
|
||||
#include"ast.h"
|
||||
#include"obj_hashtable.h"
|
||||
|
@ -126,5 +126,18 @@ expr * mk_not(ast_manager & m, expr * arg);
|
|||
*/
|
||||
expr * expand_distinct(ast_manager & m, unsigned num_args, expr * const * args);
|
||||
|
||||
#endif /* _AST_UTIL_H_ */
|
||||
/**
|
||||
\brief Collect top-level conjunctions and disjunctions.
|
||||
*/
|
||||
|
||||
void flatten_and(expr_ref_vector& result);
|
||||
|
||||
void flatten_and(expr* fml, expr_ref_vector& result);
|
||||
|
||||
void flatten_or(expr_ref_vector& result);
|
||||
|
||||
void flatten_or(expr* fml, expr_ref_vector& result);
|
||||
|
||||
|
||||
#endif /* AST_UTIL_H_ */
|
||||
|
||||
|
|
|
@ -501,13 +501,17 @@ func_decl * bv_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters, p
|
|||
func_decl * r = mk_func_decl(k, bv_size);
|
||||
if (r != 0) {
|
||||
if (arity != r->get_arity()) {
|
||||
m_manager->raise_exception("declared arity mismatches supplied arity");
|
||||
return 0;
|
||||
if (r->get_info()->is_associative())
|
||||
arity = r->get_arity();
|
||||
else {
|
||||
m_manager->raise_exception("declared arity mismatches supplied arity");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
for (unsigned i = 0; i < arity; ++i) {
|
||||
if (domain[i] != r->get_domain(i)) {
|
||||
m_manager->raise_exception("declared sorts do not match supplied sorts");
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
|
@ -566,6 +570,7 @@ func_decl * bv_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters, p
|
|||
|
||||
func_decl * bv_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters,
|
||||
unsigned num_args, expr * const * args, sort * range) {
|
||||
ast_manager& m = *m_manager;
|
||||
int bv_size;
|
||||
if (k == OP_INT2BV && get_int2bv_size(num_parameters, parameters, bv_size)) {
|
||||
// bv_size is filled in.
|
||||
|
@ -589,11 +594,35 @@ func_decl * bv_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters, p
|
|||
return decl_plugin::mk_func_decl(k, num_parameters, parameters, num_args, args, range);
|
||||
}
|
||||
else if (num_args == 0 || !get_bv_size(args[0], bv_size)) {
|
||||
m_manager->raise_exception("operator is applied to arguments of the wrong sort");
|
||||
m.raise_exception("operator is applied to arguments of the wrong sort");
|
||||
return 0;
|
||||
}
|
||||
func_decl * r = mk_func_decl(k, bv_size);
|
||||
if (r != 0) {
|
||||
if (num_args != r->get_arity()) {
|
||||
if (r->get_info()->is_associative()) {
|
||||
sort * fs = r->get_domain(0);
|
||||
for (unsigned i = 0; i < num_args; ++i) {
|
||||
if (m.get_sort(args[i]) != fs) {
|
||||
m_manager->raise_exception("declared sorts do not match supplied sorts");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
else {
|
||||
m.raise_exception("declared arity mismatches supplied arity");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
for (unsigned i = 0; i < num_args; ++i) {
|
||||
if (m.get_sort(args[i]) != r->get_domain(i)) {
|
||||
std::ostringstream buffer;
|
||||
buffer << "Argument " << mk_pp(args[i], m) << " at position " << i << " does not match declaration " << mk_pp(r, m);
|
||||
m.raise_exception(buffer.str().c_str());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
return decl_plugin::mk_func_decl(k, num_parameters, parameters, num_args, args, range);
|
||||
|
|
|
@ -16,8 +16,8 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef _BV_DECL_PLUGIN_H_
|
||||
#define _BV_DECL_PLUGIN_H_
|
||||
#ifndef BV_DECL_PLUGIN_H_
|
||||
#define BV_DECL_PLUGIN_H_
|
||||
|
||||
#include"ast.h"
|
||||
|
||||
|
@ -389,5 +389,5 @@ public:
|
|||
app * mk_bv(unsigned n, expr* const* es) { return m_manager.mk_app(get_fid(), OP_MKBV, n, es); }
|
||||
};
|
||||
|
||||
#endif /* _BV_DECL_PLUGIN_H_ */
|
||||
#endif /* BV_DECL_PLUGIN_H_ */
|
||||
|
||||
|
|
|
@ -149,10 +149,10 @@ enum status {
|
|||
*/
|
||||
static bool is_recursive_datatype(parameter const * parameters) {
|
||||
unsigned num_types = parameters[0].get_int();
|
||||
unsigned tid = parameters[1].get_int();
|
||||
unsigned top_tid = parameters[1].get_int();
|
||||
buffer<status> already_found(num_types, WHITE);
|
||||
buffer<unsigned> todo;
|
||||
todo.push_back(tid);
|
||||
todo.push_back(top_tid);
|
||||
while (!todo.empty()) {
|
||||
unsigned tid = todo.back();
|
||||
if (already_found[tid] == BLACK) {
|
||||
|
@ -198,11 +198,11 @@ static bool is_recursive_datatype(parameter const * parameters) {
|
|||
*/
|
||||
static sort_size get_datatype_size(parameter const * parameters) {
|
||||
unsigned num_types = parameters[0].get_int();
|
||||
unsigned tid = parameters[1].get_int();
|
||||
unsigned top_tid = parameters[1].get_int();
|
||||
buffer<sort_size> szs(num_types, sort_size());
|
||||
buffer<status> already_found(num_types, WHITE);
|
||||
buffer<unsigned> todo;
|
||||
todo.push_back(tid);
|
||||
todo.push_back(top_tid);
|
||||
while (!todo.empty()) {
|
||||
unsigned tid = todo.back();
|
||||
if (already_found[tid] == BLACK) {
|
||||
|
@ -280,7 +280,7 @@ static sort_size get_datatype_size(parameter const * parameters) {
|
|||
}
|
||||
}
|
||||
}
|
||||
return szs[tid];
|
||||
return szs[top_tid];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -422,8 +422,55 @@ static sort * get_type(ast_manager & m, family_id datatype_fid, sort * source_da
|
|||
}
|
||||
}
|
||||
|
||||
func_decl * datatype_decl_plugin::mk_update_field(
|
||||
unsigned num_parameters, parameter const * parameters,
|
||||
unsigned arity, sort * const * domain, sort * range) {
|
||||
decl_kind k = OP_DT_UPDATE_FIELD;
|
||||
ast_manager& m = *m_manager;
|
||||
|
||||
if (num_parameters != 1 || !parameters[0].is_ast()) {
|
||||
m.raise_exception("invalid parameters for datatype field update");
|
||||
return 0;
|
||||
}
|
||||
if (arity != 2) {
|
||||
m.raise_exception("invalid number of arguments for datatype field update");
|
||||
return 0;
|
||||
}
|
||||
func_decl* acc = 0;
|
||||
if (is_func_decl(parameters[0].get_ast())) {
|
||||
acc = to_func_decl(parameters[0].get_ast());
|
||||
}
|
||||
if (acc && !get_util().is_accessor(acc)) {
|
||||
acc = 0;
|
||||
}
|
||||
if (!acc) {
|
||||
m.raise_exception("datatype field update requires a datatype accessor as the second argument");
|
||||
return 0;
|
||||
}
|
||||
sort* dom = acc->get_domain(0);
|
||||
sort* rng = acc->get_range();
|
||||
if (dom != domain[0]) {
|
||||
m.raise_exception("first argument to field update should be a data-type");
|
||||
return 0;
|
||||
}
|
||||
if (rng != domain[1]) {
|
||||
std::ostringstream buffer;
|
||||
buffer << "second argument to field update should be " << mk_ismt2_pp(rng, m)
|
||||
<< " instead of " << mk_ismt2_pp(domain[1], m);
|
||||
m.raise_exception(buffer.str().c_str());
|
||||
return 0;
|
||||
}
|
||||
range = domain[0];
|
||||
func_decl_info info(m_family_id, k, num_parameters, parameters);
|
||||
return m.mk_func_decl(symbol("update_field"), arity, domain, range, info);
|
||||
}
|
||||
|
||||
func_decl * datatype_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters, parameter const * parameters,
|
||||
unsigned arity, sort * const * domain, sort * range) {
|
||||
|
||||
if (k == OP_DT_UPDATE_FIELD) {
|
||||
return mk_update_field(num_parameters, parameters, arity, domain, range);
|
||||
}
|
||||
if (num_parameters < 2 || !parameters[0].is_ast() || !is_sort(parameters[0].get_ast())) {
|
||||
m_manager->raise_exception("invalid parameters for datatype operator");
|
||||
return 0;
|
||||
|
@ -521,6 +568,9 @@ func_decl * datatype_decl_plugin::mk_func_decl(decl_kind k, unsigned num_paramet
|
|||
return m_manager->mk_func_decl(a_name, arity, domain, a_type, info);
|
||||
}
|
||||
break;
|
||||
case OP_DT_UPDATE_FIELD:
|
||||
UNREACHABLE();
|
||||
return 0;
|
||||
default:
|
||||
m_manager->raise_exception("invalid datatype operator kind");
|
||||
return 0;
|
||||
|
@ -607,8 +657,8 @@ bool datatype_decl_plugin::is_fully_interp(sort const * s) const {
|
|||
for (unsigned tid = 0; tid < num_types; tid++) {
|
||||
unsigned o = parameters[2 + 2*tid + 1].get_int(); // constructor offset
|
||||
unsigned num_constructors = parameters[o].get_int();
|
||||
for (unsigned s = 1; s <= num_constructors; s++) {
|
||||
unsigned k_i = parameters[o + s].get_int();
|
||||
for (unsigned si = 1; si <= num_constructors; si++) {
|
||||
unsigned k_i = parameters[o + si].get_int();
|
||||
unsigned num_accessors = parameters[k_i + 2].get_int();
|
||||
unsigned r = 0;
|
||||
for (; r < num_accessors; r++) {
|
||||
|
@ -672,6 +722,13 @@ bool datatype_decl_plugin::is_value(app * e) const {
|
|||
return true;
|
||||
}
|
||||
|
||||
void datatype_decl_plugin::get_op_names(svector<builtin_name> & op_names, symbol const & logic) {
|
||||
if (logic == symbol::null) {
|
||||
op_names.push_back(builtin_name("update-field", OP_DT_UPDATE_FIELD));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
datatype_util::datatype_util(ast_manager & m):
|
||||
m_manager(m),
|
||||
m_family_id(m.mk_family_id("datatype")),
|
||||
|
|
|
@ -16,8 +16,8 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef _DATATYPE_DECL_PLUGIN_H_
|
||||
#define _DATATYPE_DECL_PLUGIN_H_
|
||||
#ifndef DATATYPE_DECL_PLUGIN_H_
|
||||
#define DATATYPE_DECL_PLUGIN_H_
|
||||
|
||||
#include"ast.h"
|
||||
#include"tptr.h"
|
||||
|
@ -32,6 +32,7 @@ enum datatype_op_kind {
|
|||
OP_DT_CONSTRUCTOR,
|
||||
OP_DT_RECOGNISER,
|
||||
OP_DT_ACCESSOR,
|
||||
OP_DT_UPDATE_FIELD,
|
||||
LAST_DT_OP
|
||||
};
|
||||
|
||||
|
@ -149,8 +150,14 @@ public:
|
|||
|
||||
virtual bool is_unique_value(app * e) const { return is_value(e); }
|
||||
|
||||
virtual void get_op_names(svector<builtin_name> & op_names, symbol const & logic);
|
||||
|
||||
private:
|
||||
bool is_value_visit(expr * arg, ptr_buffer<app> & todo) const;
|
||||
|
||||
func_decl * mk_update_field(
|
||||
unsigned num_parameters, parameter const * parameters,
|
||||
unsigned arity, sort * const * domain, sort * range);
|
||||
};
|
||||
|
||||
class datatype_util {
|
||||
|
@ -181,9 +188,11 @@ public:
|
|||
bool is_constructor(func_decl * f) const { return is_decl_of(f, m_family_id, OP_DT_CONSTRUCTOR); }
|
||||
bool is_recognizer(func_decl * f) const { return is_decl_of(f, m_family_id, OP_DT_RECOGNISER); }
|
||||
bool is_accessor(func_decl * f) const { return is_decl_of(f, m_family_id, OP_DT_ACCESSOR); }
|
||||
bool is_update_field(func_decl * f) const { return is_decl_of(f, m_family_id, OP_DT_UPDATE_FIELD); }
|
||||
bool is_constructor(app * f) const { return is_app_of(f, m_family_id, OP_DT_CONSTRUCTOR); }
|
||||
bool is_recognizer(app * f) const { return is_app_of(f, m_family_id, OP_DT_RECOGNISER); }
|
||||
bool is_accessor(app * f) const { return is_app_of(f, m_family_id, OP_DT_ACCESSOR); }
|
||||
bool is_update_field(app * f) const { return is_app_of(f, m_family_id, OP_DT_UPDATE_FIELD); }
|
||||
ptr_vector<func_decl> const * get_datatype_constructors(sort * ty);
|
||||
unsigned get_datatype_num_constructors(sort * ty) {
|
||||
SASSERT(is_datatype(ty));
|
||||
|
@ -205,5 +214,5 @@ public:
|
|||
|
||||
};
|
||||
|
||||
#endif /* _DATATYPE_DECL_PLUGIN_H_ */
|
||||
#endif /* DATATYPE_DECL_PLUGIN_H_ */
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@ Author:
|
|||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef _SMT_DECL_COLLECTOR_H_
|
||||
#define _SMT_DECL_COLLECTOR_H_
|
||||
#ifndef SMT_DECL_COLLECTOR_H_
|
||||
#define SMT_DECL_COLLECTOR_H_
|
||||
|
||||
#include"ast.h"
|
||||
|
||||
|
@ -43,6 +43,8 @@ public:
|
|||
ast_manager & m() { return m_manager; }
|
||||
|
||||
void visit(ast * n);
|
||||
void visit(unsigned n, expr* const* es);
|
||||
void visit(expr_ref_vector const& es);
|
||||
|
||||
unsigned get_num_sorts() const { return m_sorts.size(); }
|
||||
unsigned get_num_decls() const { return m_decls.size(); }
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue