3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-23 06:13:40 +00:00

synchronizing with main repository

This commit is contained in:
nilsbecker 2019-02-22 00:19:43 +01:00
commit ec76efedbe
386 changed files with 10027 additions and 8346 deletions

View file

@ -65,7 +65,7 @@ public:
for_each_expr_core<proc, expr_fast_mark1, true, true>(p, visited, g.form(i));
}
const double total = ackr_helper::calculate_lemma_bound(p.m_fun2terms);
TRACE("ackr_bound_probe", tout << "total=" << total << std::endl;);
TRACE("ackermannize", tout << "total=" << total << std::endl;);
return result(total);
}

View file

@ -84,7 +84,7 @@ void ackr_model_converter::convert(model * source, model * destination) {
}
void ackr_model_converter::convert_constants(model * source, model * destination) {
TRACE("ackr_model", tout << "converting constants\n";);
TRACE("ackermannize", tout << "converting constants\n";);
obj_map<func_decl, func_interp*> interpretations;
model_evaluator evaluator(*source);
evaluator.set_model_completion(true);
@ -113,7 +113,7 @@ void ackr_model_converter::convert_constants(model * source, model * destination
void ackr_model_converter::add_entry(model_evaluator & evaluator,
app* term, expr* value,
obj_map<func_decl, func_interp*>& interpretations) {
TRACE("ackr_model", tout << "add_entry"
TRACE("ackermannize", tout << "add_entry"
<< mk_ismt2_pp(term, m, 2)
<< "->"
<< mk_ismt2_pp(value, m, 2) << "\n";
@ -137,7 +137,7 @@ void ackr_model_converter::add_entry(model_evaluator & evaluator,
args.push_back(std::move(arg_value));
}
if (fi->get_entry(args.c_ptr()) == nullptr) {
TRACE("ackr_model",
TRACE("ackermannize",
tout << mk_ismt2_pp(declaration, m) << " args: " << std::endl;
for (unsigned i = 0; i < args.size(); i++)
tout << mk_ismt2_pp(args.get(i), m) << std::endl;
@ -145,7 +145,7 @@ void ackr_model_converter::add_entry(model_evaluator & evaluator,
fi->insert_new_entry(args.c_ptr(), value);
}
else {
TRACE("ackr_model", tout << "entry already present\n";);
TRACE("ackermannize", tout << "entry already present\n";);
}
}

View file

@ -56,7 +56,7 @@ lbool lackr::operator() () {
if (!init()) return l_undef;
const lbool rv = m_eager ? eager() : lazy();
if (rv == l_true) m_sat->get_model(m_model);
CTRACE("lackr", rv == l_true,
CTRACE("ackermannize", rv == l_true,
model_smt2_pp(tout << "abstr_model(\n", m_m, *(m_model.get()), 2); tout << ")\n"; );
return rv;
}
@ -89,7 +89,7 @@ bool lackr::init() {
// Introduce ackermann lemma for the two given terms.
//
bool lackr::ackr(app * const t1, app * const t2) {
TRACE("lackr", tout << "ackr "
TRACE("ackermannize", tout << "ackr "
<< mk_ismt2_pp(t1, m_m, 2) << " , " << mk_ismt2_pp(t2, m_m, 2) << "\n";);
const unsigned sz = t1->get_num_args();
SASSERT(t2->get_num_args() == sz);
@ -99,7 +99,7 @@ bool lackr::ackr(app * const t1, app * const t2) {
expr * const arg2 = t2->get_arg(i);
if (m_m.are_equal(arg1, arg2)) continue; // quickly skip syntactically equal
if (m_m.are_distinct(arg1, arg2)){ // quickly abort if there are two distinct (e.g. numerals)
TRACE("lackr", tout << "never eq\n";);
TRACE("ackermannize", tout << "never eq\n";);
return false;
}
eqs.push_back(m_m.mk_eq(arg1, arg2));
@ -107,22 +107,22 @@ bool lackr::ackr(app * const t1, app * const t2) {
app * const a1 = m_info->get_abstr(t1);
app * const a2 = m_info->get_abstr(t2);
SASSERT(a1 && a2);
TRACE("lackr", tout << "abstr1 " << mk_ismt2_pp(a1, m_m, 2) << "\n";);
TRACE("lackr", tout << "abstr2 " << mk_ismt2_pp(a2, m_m, 2) << "\n";);
TRACE("ackermannize", tout << "abstr1 " << mk_ismt2_pp(a1, m_m, 2) << "\n";);
TRACE("ackermannize", tout << "abstr2 " << mk_ismt2_pp(a2, m_m, 2) << "\n";);
expr_ref lhs(m_m);
lhs = (eqs.size() == 1) ? eqs.get(0) : m_m.mk_and(eqs.size(), eqs.c_ptr());
TRACE("lackr", tout << "ackr constr lhs" << mk_ismt2_pp(lhs, m_m, 2) << "\n";);
TRACE("ackermannize", tout << "ackr constr lhs" << mk_ismt2_pp(lhs, m_m, 2) << "\n";);
expr_ref rhs(m_m.mk_eq(a1, a2),m_m);
TRACE("lackr", tout << "ackr constr rhs" << mk_ismt2_pp(rhs, m_m, 2) << "\n";);
TRACE("ackermannize", tout << "ackr constr rhs" << mk_ismt2_pp(rhs, m_m, 2) << "\n";);
expr_ref cg(m_m.mk_implies(lhs, rhs), m_m);
TRACE("lackr", tout << "ackr constr" << mk_ismt2_pp(cg, m_m, 2) << "\n";);
TRACE("ackermannize", tout << "ackr constr" << mk_ismt2_pp(cg, m_m, 2) << "\n";);
expr_ref cga(m_m);
m_info->abstract(cg, cga); // constraint needs abstraction due to nested applications
m_simp(cga);
TRACE("lackr", tout << "ackr constr abs:" << mk_ismt2_pp(cga, m_m, 2) << "\n";);
TRACE("ackermannize", tout << "ackr constr abs:" << mk_ismt2_pp(cga, m_m, 2) << "\n";);
if (m_m.is_true(cga)) return false;
m_st.m_ackrs_sz++;
m_ackrs.push_back(cga);
m_ackrs.push_back(std::move(cga));
return true;
}
@ -130,11 +130,10 @@ bool lackr::ackr(app * const t1, app * const t2) {
// Introduce the ackermann lemma for each pair of terms.
//
void lackr::eager_enc() {
TRACE("lackr", tout << "#funs: " << m_fun2terms.size() << std::endl;);
const fun2terms_map::iterator e = m_fun2terms.end();
for (fun2terms_map::iterator i = m_fun2terms.begin(); i != e; ++i) {
TRACE("ackermannize", tout << "#funs: " << m_fun2terms.size() << std::endl;);
for (auto const& kv : m_fun2terms) {
checkpoint();
app_set * const ts = i->get_value();
app_set * const ts = kv.get_value();
const app_set::iterator r = ts->end();
for (app_set::iterator j = ts->begin(); j != r; ++j) {
app_set::iterator k = j;
@ -142,10 +141,11 @@ void lackr::eager_enc() {
for (; k != r; ++k) {
app * const t1 = *j;
app * const t2 = *k;
SASSERT(t1->get_decl() == i->m_key);
SASSERT(t2->get_decl() == i->m_key);
if (t1 == t2) continue;
ackr(t1,t2);
SASSERT(t1->get_decl() == kv.m_key);
SASSERT(t2->get_decl() == kv.m_key);
if (t1 != t2) {
ackr(t1,t2);
}
}
}
}
@ -153,18 +153,15 @@ void lackr::eager_enc() {
void lackr::abstract() {
const fun2terms_map::iterator e = m_fun2terms.end();
for (fun2terms_map::iterator i = m_fun2terms.begin(); i != e; ++i) {
func_decl* const fd = i->m_key;
app_set * const ts = i->get_value();
for (auto const& kv : m_fun2terms) {
func_decl* const fd = kv.m_key;
app_set * const ts = kv.get_value();
sort* const s = fd->get_range();
const app_set::iterator r = ts->end();
for (app_set::iterator j = ts->begin(); j != r; ++j) {
for (app * t : (*ts)) {
app * const fc = m_m.mk_fresh_const(fd->get_name().str().c_str(), s);
app * const t = *j;
SASSERT(t->get_decl() == fd);
m_info->set_abstr(t, fc);
TRACE("lackr", tout << "abstr term "
TRACE("ackermannize", tout << "abstr term "
<< mk_ismt2_pp(t, m_m, 2)
<< " -> "
<< mk_ismt2_pp(fc, m_m, 2)
@ -189,7 +186,7 @@ void lackr::add_term(app* a) {
ts = alloc(app_set);
m_fun2terms.insert(fd, ts);
}
TRACE("lackr", tout << "term(" << mk_ismt2_pp(a, m_m, 2) << ")\n";);
TRACE("ackermannize", tout << "term(" << mk_ismt2_pp(a, m_m, 2) << ")\n";);
ts->insert(a);
}
@ -203,7 +200,7 @@ void lackr::push_abstraction() {
lbool lackr::eager() {
SASSERT(m_is_init);
push_abstraction();
TRACE("lackr", tout << "run sat 0\n"; );
TRACE("ackermannize", tout << "run sat 0\n"; );
const lbool rv0 = m_sat->check_sat(0, nullptr);
if (rv0 == l_false) return l_false;
eager_enc();
@ -211,7 +208,7 @@ lbool lackr::eager() {
all = m_m.mk_and(m_ackrs.size(), m_ackrs.c_ptr());
m_simp(all);
m_sat->assert_expr(all);
TRACE("lackr", tout << "run sat all\n"; );
TRACE("ackermannize", tout << "run sat all\n"; );
return m_sat->check_sat(0, nullptr);
}
@ -223,7 +220,7 @@ lbool lackr::lazy() {
while (true) {
m_st.m_it++;
checkpoint();
TRACE("lackr", tout << "lazy check: " << m_st.m_it << "\n";);
TRACE("ackermannize", tout << "lazy check: " << m_st.m_it << "\n";);
const lbool r = m_sat->check_sat(0, nullptr);
if (r == l_undef) return l_undef; // give up
if (r == l_false) return l_false; // abstraction unsat
@ -264,16 +261,15 @@ bool lackr::collect_terms() {
visited.mark(curr, true);
stack.pop_back();
break;
case AST_APP:
{
case AST_APP: {
app * const a = to_app(curr);
if (for_each_expr_args(stack, visited, a->get_num_args(), a->get_args())) {
visited.mark(curr, true);
stack.pop_back();
add_term(a);
}
}
break;
}
case AST_QUANTIFIER:
return false; // quantifiers not supported
default:

View file

@ -102,7 +102,7 @@ class lackr {
//
// Introduce congruence ackermann lemma for the two given terms.
//
bool ackr(app * const t1, app * const t2);
bool ackr(app * t1, app * t2);
//
// Introduce the ackermann lemma for each pair of terms.

View file

@ -237,7 +237,7 @@ struct lackr_model_constructor::imp {
// handle functions
if (m_ackr_helper.should_ackermannize(a)) { // handle uninterpreted
app_ref key(m_m.mk_app(a->get_decl(), values.c_ptr()), m_m);
if (!make_value_uninterpreted_function(a, values, key.get(), result)) {
if (!make_value_uninterpreted_function(a, key.get(), result)) {
return false;
}
}
@ -284,7 +284,6 @@ struct lackr_model_constructor::imp {
}
bool make_value_uninterpreted_function(app* a,
expr_ref_vector& values,
app* key,
expr_ref& result) {
// get ackermann constant
@ -370,15 +369,12 @@ lackr_model_constructor::lackr_model_constructor(ast_manager& m, ackr_info_ref i
{}
lackr_model_constructor::~lackr_model_constructor() {
if (m_imp) dealloc(m_imp);
dealloc(m_imp);
}
bool lackr_model_constructor::check(model_ref& abstr_model) {
m_conflicts.reset();
if (m_imp) {
dealloc(m_imp);
m_imp = nullptr;
}
dealloc(m_imp);
m_imp = alloc(lackr_model_constructor::imp, m_m, m_info, abstr_model, m_conflicts);
const bool rv = m_imp->check();
m_state = rv ? CHECKED : CONFLICT;

View file

@ -34,6 +34,7 @@ Revision History:
#include "ast/rewriter/var_subst.h"
#include "ast/rewriter/expr_safe_replace.h"
#include "ast/rewriter/recfun_replace.h"
#include "ast/rewriter/seq_rewriter.h"
#include "ast/pp.h"
#include "util/scoped_ctrl_c.h"
#include "util/cancel_eh.h"
@ -733,6 +734,7 @@ extern "C" {
Z3_CATCH_RETURN(Z3_L_UNDEF);
}
static Z3_ast simplify(Z3_context c, Z3_ast _a, Z3_params _p) {
Z3_TRY;
RESET_ERROR_CODE();
@ -742,6 +744,7 @@ extern "C" {
unsigned timeout = p.get_uint("timeout", mk_c(c)->get_timeout());
bool use_ctrl_c = p.get_bool("ctrl_c", false);
th_rewriter m_rw(m, p);
m_rw.set_solver(alloc(api::seq_expr_solver, m, p));
expr_ref result(m);
cancel_eh<reslimit> eh(m.limit());
api::context::set_interruptable si(*(mk_c(c)), eh);

View file

@ -68,10 +68,17 @@ extern "C" {
}
Z3_config Z3_API Z3_mk_config(void) {
memory::initialize(UINT_MAX);
LOG_Z3_mk_config();
Z3_config r = reinterpret_cast<Z3_config>(alloc(context_params));
RETURN_Z3(r);
try {
memory::initialize(UINT_MAX);
LOG_Z3_mk_config();
Z3_config r = reinterpret_cast<Z3_config>(alloc(context_params));
RETURN_Z3(r);
} catch (z3_exception & ex) {
// The error handler is only available for contexts
// Just throw a warning.
warning_msg("%s", ex.msg());
return nullptr;
}
}
void Z3_API Z3_del_config(Z3_config c) {

View file

@ -109,13 +109,10 @@ namespace api {
context::~context() {
m_last_obj = nullptr;
u_map<api::object*>::iterator it = m_allocated_objects.begin();
while (it != m_allocated_objects.end()) {
api::object* val = it->m_value;
DEBUG_CODE(warning_msg("Uncollected memory: %d: %s", it->m_key, typeid(*val).name()););
m_allocated_objects.remove(it->m_key);
for (auto& kv : m_allocated_objects) {
api::object* val = kv.m_value;
DEBUG_CODE(warning_msg("Uncollected memory: %d: %s", kv.m_key, typeid(*val).name()););
dealloc(val);
it = m_allocated_objects.begin();
}
}
@ -489,9 +486,3 @@ extern "C" {
}
};
Z3_API ast_manager& Z3_get_manager(Z3_context c) {
return mk_c(c)->m();
}

View file

@ -38,6 +38,9 @@ Revision History:
#include "cmd_context/cmd_context.h"
#include "api/api_polynomial.h"
#include "util/hashtable.h"
#include "ast/rewriter/seq_rewriter.h"
#include "smt/smt_solver.h"
#include "solver/solver.h"
namespace smtlib {
class parser;
@ -49,6 +52,24 @@ namespace realclosure {
namespace api {
class seq_expr_solver : public expr_solver {
ast_manager& m;
params_ref const& p;
solver_ref s;
public:
seq_expr_solver(ast_manager& m, params_ref const& p): m(m), p(p) {}
lbool check_sat(expr* e) {
if (!s) {
s = mk_smt_solver(m, p, symbol("ALL"));
}
s->push();
s->assert_expr(e);
lbool r = s->check_sat();
s->pop(1);
return r;
}
};
class context : public tactic_manager {
struct add_plugins { add_plugins(ast_manager & m); };

View file

@ -242,8 +242,8 @@ extern "C" {
RETURN_Z3(nullptr);
}
api::context * ctx = mk_c(c);
expr * a = negative != 0 ? ctx->fpautil().mk_ninf(to_sort(s)) :
ctx->fpautil().mk_pinf(to_sort(s));
expr * a = negative ? ctx->fpautil().mk_ninf(to_sort(s)) :
ctx->fpautil().mk_pinf(to_sort(s));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(nullptr);
@ -259,8 +259,8 @@ extern "C" {
RETURN_Z3(nullptr);
}
api::context * ctx = mk_c(c);
expr * a = negative != 0 ? ctx->fpautil().mk_nzero(to_sort(s)) :
ctx->fpautil().mk_pzero(to_sort(s));
expr * a = negative ? ctx->fpautil().mk_nzero(to_sort(s)) :
ctx->fpautil().mk_pzero(to_sort(s));
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
Z3_CATCH_RETURN(nullptr);
@ -351,7 +351,7 @@ extern "C" {
ctx->fpautil().fm().set(tmp,
ctx->fpautil().get_ebits(to_sort(ty)),
ctx->fpautil().get_sbits(to_sort(ty)),
sgn != 0, exp, sig);
sgn, exp, sig);
expr * a = ctx->fpautil().mk_value(tmp);
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));
@ -371,7 +371,7 @@ extern "C" {
ctx->fpautil().fm().set(tmp,
ctx->fpautil().get_ebits(to_sort(ty)),
ctx->fpautil().get_sbits(to_sort(ty)),
sgn != 0, exp, sig);
sgn, exp, sig);
expr * a = ctx->fpautil().mk_value(tmp);
ctx->save_ast_trail(a);
RETURN_Z3(of_expr(a));

View file

@ -79,11 +79,7 @@ extern "C" {
Z3_TRY;
LOG_Z3_model_has_interp(c, m, a);
CHECK_NON_NULL(m, 0);
if (to_model_ref(m)->has_interpretation(to_func_decl(a))) {
return true;
} else {
return false;
}
return to_model_ref(m)->has_interpretation(to_func_decl(a));
Z3_CATCH_RETURN(false);
}
@ -165,7 +161,10 @@ extern "C" {
CHECK_NON_NULL(m, false);
CHECK_IS_EXPR(t, false);
model * _m = to_model_ref(m);
expr_ref result(mk_c(c)->m());
params_ref p;
ast_manager& mgr = mk_c(c)->m();
_m->set_solver(alloc(api::seq_expr_solver, mgr, p));
expr_ref result(mgr);
model::scoped_model_completion _scm(*_m, model_completion);
result = (*_m)(to_expr(t));
mk_c(c)->save_ast_trail(result.get());
@ -472,7 +471,7 @@ extern "C" {
model_smt2_pp(buffer, mk_c(c)->m(), *(to_model_ref(m)), 0);
// Hack for removing the trailing '\n'
result = buffer.str();
if (result.size() != 0)
if (!result.empty())
result.resize(result.size()-1);
}
else {

View file

@ -198,19 +198,19 @@ extern "C" {
mpf_rounding_mode rm;
if (mk_c(c)->fpautil().is_rm_numeral(to_expr(a), rm)) {
switch (rm) {
case OP_FPA_RM_NEAREST_TIES_TO_EVEN:
case MPF_ROUND_NEAREST_TEVEN:
return mk_c(c)->mk_external_string("roundNearestTiesToEven");
break;
case OP_FPA_RM_NEAREST_TIES_TO_AWAY:
case MPF_ROUND_NEAREST_TAWAY:
return mk_c(c)->mk_external_string("roundNearestTiesToAway");
break;
case OP_FPA_RM_TOWARD_POSITIVE:
case MPF_ROUND_TOWARD_POSITIVE:
return mk_c(c)->mk_external_string("roundTowardPositive");
break;
case OP_FPA_RM_TOWARD_NEGATIVE:
case MPF_ROUND_TOWARD_NEGATIVE:
return mk_c(c)->mk_external_string("roundTowardNegative");
break;
case OP_FPA_RM_TOWARD_ZERO:
case MPF_ROUND_TOWARD_ZERO:
default:
return mk_c(c)->mk_external_string("roundTowardZero");
break;

View file

@ -79,6 +79,16 @@ extern "C" {
Z3_CATCH;
}
void Z3_API Z3_optimize_assert_and_track(Z3_context c, Z3_optimize o, Z3_ast a, Z3_ast t) {
Z3_TRY;
LOG_Z3_optimize_assert_and_track(c, o, a, t);
RESET_ERROR_CODE();
CHECK_FORMULA(a,);
CHECK_FORMULA(t,);
to_optimize_ptr(o)->add_hard_constraint(to_expr(a), to_expr(t));
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);

View file

@ -66,7 +66,7 @@ extern "C" {
Z3_TRY;
LOG_Z3_params_set_bool(c, p, k, v);
RESET_ERROR_CODE();
to_params(p)->m_params.set_bool(norm_param_name(to_symbol(k)).c_str(), v != 0);
to_params(p)->m_params.set_bool(norm_param_name(to_symbol(k)).c_str(), v);
Z3_CATCH;
}

View file

@ -274,7 +274,7 @@ extern "C" {
RESET_ERROR_CODE();
reset_rcf_cancel(c);
std::ostringstream buffer;
rcfm(c).display(buffer, to_rcnumeral(a), compact != 0, html != 0);
rcfm(c).display(buffer, to_rcnumeral(a), compact, html);
return mk_c(c)->mk_external_string(buffer.str());
Z3_CATCH_RETURN("");
}

View file

@ -106,8 +106,8 @@ extern "C" {
SET_ERROR_CODE(Z3_INVALID_ARG, "expression is not a string literal");
return "";
}
std::string result = str.encode();
return mk_c(c)->mk_external_string(result);
std::string s = str.encode();
return mk_c(c)->mk_external_string(s);
Z3_CATCH_RETURN("");
}

View file

@ -163,12 +163,45 @@ extern "C" {
to_solver_ref(s)->set_model_converter(ctx->get_model_converter());
}
static void solver_from_dimacs_stream(Z3_context c, Z3_solver s, std::istream& is) {
init_solver(c, s);
ast_manager& m = to_solver_ref(s)->get_manager();
std::stringstream err;
sat::solver solver(to_solver_ref(s)->get_params(), m.limit());
if (!parse_dimacs(is, err, solver)) {
SET_ERROR_CODE(Z3_PARSER_ERROR, err.str().c_str());
return;
}
sat2goal s2g;
ref<sat2goal::mc> mc;
atom2bool_var a2b(m);
for (unsigned v = 0; v < solver.num_vars(); ++v) {
a2b.insert(m.mk_const(symbol(v), m.mk_bool_sort()), v);
}
goal g(m);
s2g(solver, a2b, to_solver_ref(s)->get_params(), g, mc);
for (unsigned i = 0; i < g.size(); ++i) {
to_solver_ref(s)->assert_expr(g.form(i));
}
}
// DIMACS files start with "p cnf" and number of variables/clauses.
// This is not legal SMT syntax, so use the DIMACS parser.
static bool is_dimacs_string(Z3_string c_str) {
return c_str[0] == 'p' && c_str[1] == ' ' && c_str[2] == 'c';
}
void Z3_API Z3_solver_from_string(Z3_context c, Z3_solver s, Z3_string c_str) {
Z3_TRY;
LOG_Z3_solver_from_string(c, s, c_str);
std::string str(c_str);
std::istringstream is(str);
solver_from_stream(c, s, is);
if (is_dimacs_string(c_str)) {
solver_from_dimacs_stream(c, s, is);
}
else {
solver_from_stream(c, s, is);
}
Z3_CATCH;
}
@ -181,25 +214,8 @@ extern "C" {
if (!is) {
SET_ERROR_CODE(Z3_FILE_ACCESS_ERROR, nullptr);
}
else if (ext && std::string("dimacs") == ext) {
ast_manager& m = to_solver_ref(s)->get_manager();
std::stringstream err;
sat::solver solver(to_solver_ref(s)->get_params(), m.limit());
if (!parse_dimacs(is, err, solver)) {
SET_ERROR_CODE(Z3_PARSER_ERROR, err.str().c_str());
return;
}
sat2goal s2g;
ref<sat2goal::mc> mc;
atom2bool_var a2b(m);
for (unsigned v = 0; v < solver.num_vars(); ++v) {
a2b.insert(m.mk_const(symbol(v), m.mk_bool_sort()), v);
}
goal g(m);
s2g(solver, a2b, to_solver_ref(s)->get_params(), g, mc);
for (unsigned i = 0; i < g.size(); ++i) {
to_solver_ref(s)->assert_expr(g.form(i));
}
else if (ext && (std::string("dimacs") == ext || std::string("cnf") == ext)) {
solver_from_dimacs_stream(c, s, is);
}
else {
solver_from_stream(c, s, is);
@ -369,7 +385,7 @@ extern "C" {
init_solver(c, s);
Z3_ast_vector_ref * v = alloc(Z3_ast_vector_ref, *mk_c(c), mk_c(c)->m());
mk_c(c)->save_object(v);
expr_ref_vector fmls = to_solver_ref(s)->get_units(mk_c(c)->m());
expr_ref_vector fmls = to_solver_ref(s)->get_units();
for (expr* f : fmls) {
v->m_ast_vector.push_back(f);
}
@ -384,7 +400,7 @@ extern "C" {
init_solver(c, s);
Z3_ast_vector_ref * v = alloc(Z3_ast_vector_ref, *mk_c(c), mk_c(c)->m());
mk_c(c)->save_object(v);
expr_ref_vector fmls = to_solver_ref(s)->get_non_units(mk_c(c)->m());
expr_ref_vector fmls = to_solver_ref(s)->get_non_units();
for (expr* f : fmls) {
v->m_ast_vector.push_back(f);
}
@ -392,6 +408,53 @@ extern "C" {
Z3_CATCH_RETURN(nullptr);
}
void Z3_API Z3_solver_get_levels(Z3_context c, Z3_solver s, Z3_ast_vector literals, unsigned sz, unsigned levels[]) {
Z3_TRY;
LOG_Z3_solver_get_levels(c, s, literals, sz, levels);
RESET_ERROR_CODE();
init_solver(c, s);
if (sz != Z3_ast_vector_size(c, literals)) {
SET_ERROR_CODE(Z3_IOB, nullptr);
return;
}
ptr_vector<expr> _vars;
for (unsigned i = 0; i < sz; ++i) {
expr* e = to_expr(Z3_ast_vector_get(c, literals, i));
mk_c(c)->m().is_not(e, e);
_vars.push_back(e);
}
unsigned_vector _levels(sz);
to_solver_ref(s)->get_levels(_vars, _levels);
for (unsigned i = 0; i < sz; ++i) {
levels[i] = _levels[i];
}
Z3_CATCH;
}
void Z3_API Z3_solver_set_activity(Z3_context c, Z3_solver s, Z3_ast a, double activity) {
Z3_TRY;
LOG_Z3_solver_set_activity(c, s, a, activity);
RESET_ERROR_CODE();
init_solver(c, s);
to_solver_ref(s)->set_activity(to_expr(a), activity);
Z3_CATCH;
}
Z3_ast_vector Z3_API Z3_solver_get_trail(Z3_context c, Z3_solver s) {
Z3_TRY;
LOG_Z3_solver_get_trail(c, s);
RESET_ERROR_CODE();
init_solver(c, s);
Z3_ast_vector_ref * v = alloc(Z3_ast_vector_ref, *mk_c(c), mk_c(c)->m());
mk_c(c)->save_object(v);
expr_ref_vector trail = to_solver_ref(s)->get_trail();
for (expr* f : trail) {
v->m_ast_vector.push_back(f);
}
RETURN_Z3(of_ast_vector(v));
Z3_CATCH_RETURN(nullptr);
}
static Z3_lbool _solver_check(Z3_context c, Z3_solver s, unsigned num_assumptions, Z3_ast const assumptions[]) {
for (unsigned i = 0; i < num_assumptions; i++) {
if (!is_expr(to_ast(assumptions[i]))) {
@ -532,6 +595,17 @@ extern "C" {
Z3_CATCH_RETURN("");
}
Z3_string Z3_API Z3_solver_to_dimacs_string(Z3_context c, Z3_solver s) {
Z3_TRY;
LOG_Z3_solver_to_string(c, s);
RESET_ERROR_CODE();
init_solver(c, s);
std::ostringstream buffer;
to_solver_ref(s)->display_dimacs(buffer);
return mk_c(c)->mk_external_string(buffer.str());
Z3_CATCH_RETURN("");
}
Z3_lbool Z3_API Z3_get_implied_equalities(Z3_context c,
Z3_solver s,

View file

@ -388,6 +388,7 @@ namespace z3 {
template<typename T2>
array(ast_vector_tpl<T2> const & v);
~array() { delete[] m_array; }
void resize(unsigned sz) { delete[] m_array; m_size = sz; m_array = new T[sz]; }
unsigned size() const { return m_size; }
T & operator[](int i) { assert(0 <= i); assert(static_cast<unsigned>(i) < m_size); return m_array[i]; }
T const & operator[](int i) const { assert(0 <= i); assert(static_cast<unsigned>(i) < m_size); return m_array[i]; }
@ -505,7 +506,7 @@ namespace z3 {
out << Z3_ast_to_string(n.ctx(), n.m_ast); return out;
}
inline bool eq(ast const & a, ast const & b) { return Z3_is_eq_ast(a.ctx(), a, b) != 0; }
inline bool eq(ast const & a, ast const & b) { return Z3_is_eq_ast(a.ctx(), a, b); }
/**
@ -518,6 +519,12 @@ namespace z3 {
sort(context & c, Z3_ast a):ast(c, a) {}
sort(sort const & s):ast(s) {}
operator Z3_sort() const { return reinterpret_cast<Z3_sort>(m_ast); }
/**
\brief retrieve unique identifier for func_decl.
*/
unsigned id() const { unsigned r = Z3_get_sort_id(ctx(), *this); check_error(); return r; }
/**
\brief Return true if this sort and \c s are equal.
*/
@ -615,6 +622,11 @@ namespace z3 {
operator Z3_func_decl() const { return reinterpret_cast<Z3_func_decl>(m_ast); }
func_decl & operator=(func_decl const & s) { return static_cast<func_decl&>(ast::operator=(s)); }
/**
\brief retrieve unique identifier for func_decl.
*/
unsigned id() const { unsigned r = Z3_get_func_decl_id(ctx(), *this); check_error(); return r; }
unsigned arity() const { return Z3_get_arity(ctx(), *this); }
sort domain(unsigned i) const { assert(i < arity()); Z3_sort r = Z3_get_domain(ctx(), *this, i); check_error(); return sort(ctx(), r); }
sort range() const { Z3_sort r = Z3_get_range(ctx(), *this); check_error(); return sort(ctx(), r); }
@ -713,10 +725,10 @@ namespace z3 {
small integers, 64 bit integers or rational or decimal strings.
*/
bool is_numeral() const { return kind() == Z3_NUMERAL_AST; }
bool is_numeral_i64(int64_t& i) const { bool r = 0 != Z3_get_numeral_int64(ctx(), m_ast, &i); check_error(); return r;}
bool is_numeral_u64(uint64_t& i) const { bool r = 0 != Z3_get_numeral_uint64(ctx(), m_ast, &i); check_error(); return r;}
bool is_numeral_i(int& i) const { bool r = 0 != Z3_get_numeral_int(ctx(), m_ast, &i); check_error(); return r;}
bool is_numeral_u(unsigned& i) const { bool r = 0 != Z3_get_numeral_uint(ctx(), m_ast, &i); check_error(); return r;}
bool is_numeral_i64(int64_t& i) const { bool r = Z3_get_numeral_int64(ctx(), m_ast, &i); check_error(); return r;}
bool is_numeral_u64(uint64_t& i) const { bool r = Z3_get_numeral_uint64(ctx(), m_ast, &i); check_error(); return r;}
bool is_numeral_i(int& i) const { bool r = Z3_get_numeral_int(ctx(), m_ast, &i); check_error(); return r;}
bool is_numeral_u(unsigned& i) const { bool r = Z3_get_numeral_uint(ctx(), m_ast, &i); check_error(); return r;}
bool is_numeral(std::string& s) const { if (!is_numeral()) return false; s = Z3_get_numeral_string(ctx(), m_ast); check_error(); return true; }
bool is_numeral(std::string& s, unsigned precision) const { if (!is_numeral()) return false; s = Z3_get_numeral_decimal_string(ctx(), m_ast, precision); check_error(); return true; }
bool is_numeral(double& d) const { if (!is_numeral()) return false; d = Z3_get_numeral_double(ctx(), m_ast); check_error(); return true; }
@ -736,15 +748,15 @@ namespace z3 {
/**
\brief Return true if this expression is a universal quantifier.
*/
bool is_forall() const { return 0 != Z3_is_quantifier_forall(ctx(), m_ast); }
bool is_forall() const { return Z3_is_quantifier_forall(ctx(), m_ast); }
/**
\brief Return true if this expression is an existential quantifier.
*/
bool is_exists() const { return 0 != Z3_is_quantifier_exists(ctx(), m_ast); }
bool is_exists() const { return Z3_is_quantifier_exists(ctx(), m_ast); }
/**
\brief Return true if this expression is a lambda expression.
*/
bool is_lambda() const { return 0 != Z3_is_lambda(ctx(), m_ast); }
bool is_lambda() const { return Z3_is_lambda(ctx(), m_ast); }
/**
\brief Return true if this expression is a variable.
@ -753,12 +765,12 @@ namespace z3 {
/**
\brief Return true if expression is an algebraic number.
*/
bool is_algebraic() const { return 0 != Z3_is_algebraic_number(ctx(), m_ast); }
bool is_algebraic() const { return Z3_is_algebraic_number(ctx(), m_ast); }
/**
\brief Return true if this expression is well sorted (aka type correct).
*/
bool is_well_sorted() const { bool r = Z3_is_well_sorted(ctx(), m_ast) != 0; check_error(); return r; }
bool is_well_sorted() const { bool r = Z3_is_well_sorted(ctx(), m_ast); check_error(); return r; }
/**
\brief Return string representation of numeral or algebraic number
@ -771,6 +783,11 @@ namespace z3 {
return std::string(Z3_get_numeral_decimal_string(ctx(), m_ast, precision));
}
/**
\brief retrieve unique identifier for expression.
*/
unsigned id() const { unsigned r = Z3_get_ast_id(ctx(), m_ast); check_error(); return r; }
/**
\brief Return int value of numeral, throw if result cannot fit in
machine int
@ -1720,6 +1737,10 @@ namespace z3 {
m_vector = s.m_vector;
return *this;
}
ast_vector_tpl& set(unsigned idx, ast& a) {
Z3_ast_vector_set(ctx(), m_vector, idx, a);
return *this;
}
/*
Disabled pending C++98 build upgrade
bool contains(T const& x) const {
@ -1746,6 +1767,9 @@ namespace z3 {
++m_index;
return *this;
}
void set(T& arg) {
Z3_ast_vector_set(m_vector->ctx(), *m_vector, m_index, arg);
}
iterator operator++(int) { iterator tmp = *this; ++m_index; return tmp; }
T * operator->() const { return &(operator*()); }
T operator*() const { return (*m_vector)[m_index]; }
@ -2073,7 +2097,7 @@ namespace z3 {
// for function f.
bool has_interp(func_decl f) const {
check_context(*this, f);
return 0 != Z3_model_has_interp(ctx(), m_model, f);
return Z3_model_has_interp(ctx(), m_model, f);
}
func_interp add_func_interp(func_decl& f, expr& else_val) {
@ -2112,8 +2136,8 @@ namespace z3 {
}
unsigned size() const { return Z3_stats_size(ctx(), m_stats); }
std::string key(unsigned i) const { Z3_string s = Z3_stats_get_key(ctx(), m_stats, i); check_error(); return s; }
bool is_uint(unsigned i) const { bool r = Z3_stats_is_uint(ctx(), m_stats, i); check_error(); return r != 0; }
bool is_double(unsigned i) const { bool r = Z3_stats_is_double(ctx(), m_stats, i); check_error(); return r != 0; }
bool is_uint(unsigned i) const { bool r = Z3_stats_is_uint(ctx(), m_stats, i); check_error(); return r; }
bool is_double(unsigned i) const { bool r = Z3_stats_is_double(ctx(), m_stats, i); check_error(); return r; }
unsigned uint_value(unsigned i) const { unsigned r = Z3_stats_get_uint_value(ctx(), m_stats, i); check_error(); return r; }
double double_value(unsigned i) const { double r = Z3_stats_get_double_value(ctx(), m_stats, i); check_error(); return r; }
friend std::ostream & operator<<(std::ostream & out, stats const & s);
@ -2210,6 +2234,18 @@ namespace z3 {
expr_vector assertions() const { Z3_ast_vector r = Z3_solver_get_assertions(ctx(), m_solver); check_error(); return expr_vector(ctx(), r); }
expr_vector non_units() const { Z3_ast_vector r = Z3_solver_get_non_units(ctx(), m_solver); check_error(); return expr_vector(ctx(), r); }
expr_vector units() const { Z3_ast_vector r = Z3_solver_get_units(ctx(), m_solver); check_error(); return expr_vector(ctx(), r); }
expr_vector trail() const { Z3_ast_vector r = Z3_solver_get_trail(ctx(), m_solver); check_error(); return expr_vector(ctx(), r); }
expr_vector trail(array<unsigned>& levels) const {
Z3_ast_vector r = Z3_solver_get_trail(ctx(), m_solver);
check_error();
expr_vector result(ctx(), r);
unsigned sz = result.size();
levels.resize(sz);
Z3_solver_get_levels(ctx(), m_solver, r, sz, levels.ptr());
check_error();
return result;
}
void set_activity(expr const& lit, double act) { Z3_solver_set_activity(ctx(), m_solver, lit, act); }
expr proof() const { Z3_ast r = Z3_solver_get_proof(ctx(), m_solver); check_error(); return expr(ctx(), r); }
friend std::ostream & operator<<(std::ostream & out, solver const & s);
@ -2233,6 +2269,8 @@ namespace z3 {
fml));
}
std::string dimacs() const { return std::string(Z3_solver_to_dimacs_string(ctx(), m_solver)); }
param_descrs get_param_descrs() { return param_descrs(ctx(), Z3_solver_get_param_descrs(ctx(), m_solver)); }
@ -2353,12 +2391,12 @@ namespace z3 {
unsigned size() const { return Z3_goal_size(ctx(), m_goal); }
expr operator[](int i) const { assert(0 <= i); Z3_ast r = Z3_goal_formula(ctx(), m_goal, i); check_error(); return expr(ctx(), r); }
Z3_goal_prec precision() const { return Z3_goal_precision(ctx(), m_goal); }
bool inconsistent() const { return Z3_goal_inconsistent(ctx(), m_goal) != 0; }
bool inconsistent() const { return Z3_goal_inconsistent(ctx(), m_goal); }
unsigned depth() const { return Z3_goal_depth(ctx(), m_goal); }
void reset() { Z3_goal_reset(ctx(), m_goal); }
unsigned num_exprs() const { return Z3_goal_num_exprs(ctx(), m_goal); }
bool is_decided_sat() const { return Z3_goal_is_decided_sat(ctx(), m_goal) != 0; }
bool is_decided_unsat() const { return Z3_goal_is_decided_unsat(ctx(), m_goal) != 0; }
bool is_decided_sat() const { return Z3_goal_is_decided_sat(ctx(), m_goal); }
bool is_decided_unsat() const { return Z3_goal_is_decided_unsat(ctx(), m_goal); }
model convert_model(model const & m) const {
check_context(*this, m);
Z3_model new_m = Z3_goal_convert_model(ctx(), m_goal, m);
@ -2609,6 +2647,11 @@ namespace z3 {
strm << weight;
return handle(Z3_optimize_assert_soft(ctx(), m_opt, e, strm.str().c_str(), 0));
}
void add(expr const& e, expr const& t) {
assert(e.is_bool());
Z3_optimize_assert_and_track(ctx(), m_opt, e, t);
}
handle add(expr const& e, char const* weight) {
assert(e.is_bool());
return handle(Z3_optimize_assert_soft(ctx(), m_opt, e, weight, 0));

View file

@ -1,12 +1,10 @@
find_package(DotNetToolchain REQUIRED)
find_package(Dotnet REQUIRED)
# Configure AssemblyInfo.cs
set(VER_MAJOR "${Z3_VERSION_MAJOR}")
set(VER_MINOR "${Z3_VERSION_MINOR}")
set(VER_BUILD "${Z3_VERSION_PATCH}")
set(VER_REVISION "${Z3_VERSION_TWEAK}")
set(Z3_DOTNET_ASSEMBLY_INFO_FILE "${CMAKE_CURRENT_BINARY_DIR}/Properties/AssemblyInfo.cs")
configure_file("Properties/AssemblyInfo.cs.in" "${Z3_DOTNET_ASSEMBLY_INFO_FILE}" @ONLY)
# Generate Native.cs
set(Z3_DOTNET_NATIVE_FILE "${CMAKE_CURRENT_BINARY_DIR}/Native.cs")
@ -127,160 +125,64 @@ endforeach()
list(APPEND Z3_DOTNET_ASSEMBLY_SOURCES
"${Z3_DOTNET_CONST_FILE}"
"${Z3_DOTNET_NATIVE_FILE}"
"${Z3_DOTNET_ASSEMBLY_INFO_FILE}"
)
# ``csc.exe`` doesn't like UNIX style paths so convert them
# if necessary first to native paths.
set(Z3_DOTNET_ASSEMBLY_SOURCES_NATIVE_PATH "")
foreach (csfile_path ${Z3_DOTNET_ASSEMBLY_SOURCES})
file(TO_NATIVE_PATH "${csfile_path}" csfile_path_native)
list(APPEND Z3_DOTNET_ASSEMBLY_SOURCES_NATIVE_PATH "${csfile_path_native}")
# Generate <Compile Include="files.cs" /> items
set(Z3_DOTNET_COMPILE_ITEMS "")
foreach(csfile ${Z3_DOTNET_ASSEMBLY_SOURCES})
set(Z3_DOTNET_COMPILE_ITEMS "${Z3_DOTNET_COMPILE_ITEMS}\n <Compile Include=\"${csfile}\" />")
endforeach()
set(CSC_FLAGS "")
if (DOTNET_TOOLCHAIN_IS_WINDOWS)
# FIXME: Why use these flags?
# Note these flags have been copied from the Python build system.
list(APPEND CSC_FLAGS
"/noconfig"
"/nostdlib+"
"/reference:mscorlib.dll"
)
elseif (DOTNET_TOOLCHAIN_IS_MONO)
# We need to give the assembly a strong name so that it can be installed
# into the GAC.
list(APPEND CSC_FLAGS
"/keyfile:${CMAKE_CURRENT_SOURCE_DIR}/Microsoft.Z3.snk"
)
# FindDotnet.cmake forwards CMake build type to MSBuild.
# And thus we can put the conditional properties in the project file.
# Note, nuget package file names do not have the ${VER_REV} part.
set(Z3_DOTNET_NUPKG_VERSION "${VER_MAJOR}.${VER_MINOR}.${VER_BUILD}")
if("${TARGET_ARCHITECTURE}" STREQUAL "i686")
set(Z3_DOTNET_PLATFORM "x86")
else()
message(FATAL_ERROR "Unknown .NET toolchain")
set(Z3_DOTNET_PLATFORM "AnyCPU")
endif()
# Common flags
list(APPEND CSC_FLAGS
"/unsafe+"
"/nowarn:1701,1702"
"/errorreport:prompt"
"/warn:4"
"/reference:System.Core.dll"
"/reference:System.dll"
"/reference:System.Numerics.dll"
"/filealign:512" # Why?
"/target:library"
)
# TODO conditional for signing. we can then enable the ``Release_delaysign`` configuration
# Set the build type flags. The build type for the assembly roughly corresponds
# with the native code build type.
list(APPEND CSC_FLAGS
# Debug flags, expands to nothing if we aren't doing a debug build
"$<$<CONFIG:Debug>:/debug+>"
"$<$<CONFIG:Debug>:/debug:full>"
"$<$<CONFIG:Debug>:/optimize->"
# This has to be quoted otherwise the ``;`` is interpreted as a command separator
"$<$<CONFIG:Debug>:\"/define:DEBUG$<SEMICOLON>TRACE\">"
# Release flags, expands to nothing if we are doing a debug build
"$<$<NOT:$<CONFIG:Debug>>:/optimize+>"
)
# Mono's gacutil crashes when trying to install an assembly if we set the
# platform in some cases, so only set it on Windows. This bug has been
# reported at https://bugzilla.xamarin.com/show_bug.cgi?id=39955 . However mono
# ignores the platform of an assembly when running it (
# http://lists.ximian.com/pipermail/mono-devel-list/2015-November/043370.html )
# so this shouldn't matter in practice.
if (DOTNET_TOOLCHAIN_IS_WINDOWS)
# Set platform for assembly
if ("${TARGET_ARCHITECTURE}" STREQUAL "x86_64")
list(APPEND CSC_FLAGS "/platform:x64")
elseif ("${TARGET_ARCHITECTURE}" STREQUAL "i686")
list(APPEND CSC_FLAGS "/platform:x86")
endif()
endif()
# FIXME: Ideally we should emit files into a configuration specific directory
# when using multi-configuration generators so that the files generated by each
# configuration don't clobber each other. Unfortunately the ``get_property()``
# command only works correctly for single configuration generators so we can't
# use it. We also can't use ``$<TARGET_FILE_DIR:libz3>`` because the ``OUTPUT``
# argument to ``add_custom_commands()`` won't accept it.
# See http://public.kitware.com/pipermail/cmake/2016-March/063101.html
#
# For now just output file to the root binary directory like the Python build
# system does and emit a warning when appropriate.
if (DEFINED CMAKE_CONFIGURATION_TYPES)
# Multi-configuration build (e.g. Visual Studio and Xcode).
message(WARNING "You are using a multi-configuration generator. The build rules for"
" the \".NET\" bindings currently do not emit files per configuration so previously"
" generated files for other configurations will be overwritten.")
endif()
set(Z3_DOTNET_ASSEMBLY_OUTPUT_DIR "${CMAKE_BINARY_DIR}")
set(Z3_DOTNET_ASSEMBLY_NAME "Microsoft.Z3.dll")
set(Z3_DOTNET_ASSEMBLY_DLL "${Z3_DOTNET_ASSEMBLY_OUTPUT_DIR}/${Z3_DOTNET_ASSEMBLY_NAME}")
# csc.exe doesn't work with UNIX style paths so convert to native path
file(TO_NATIVE_PATH "${Z3_DOTNET_ASSEMBLY_DLL}" Z3_DOTNET_ASSEMBLY_DLL_NATIVE_PATH)
set(Z3_DOTNET_ASSEMBLY_DLL_DOC "${Z3_DOTNET_ASSEMBLY_OUTPUT_DIR}/Microsoft.Z3.xml")
file(TO_NATIVE_PATH "${Z3_DOTNET_ASSEMBLY_DLL_DOC}" Z3_DOTNET_ASSEMBLY_DLL_DOC_NATIVE_PATH)
add_custom_command(OUTPUT "${Z3_DOTNET_ASSEMBLY_DLL}" "${Z3_DOTNET_ASSEMBLY_DLL_DOC}"
COMMAND
"${DOTNET_CSC_EXECUTABLE}"
${CSC_FLAGS}
"/out:${Z3_DOTNET_ASSEMBLY_DLL_NATIVE_PATH}"
"/doc:${Z3_DOTNET_ASSEMBLY_DLL_DOC_NATIVE_PATH}"
${Z3_DOTNET_ASSEMBLY_SOURCES_NATIVE_PATH}
DEPENDS
${Z3_DOTNET_ASSEMBLY_SOURCES}
libz3
WORKING_DIRECTORY "${Z3_DOTNET_ASSEMBLY_OUTPUT_DIR}"
COMMENT "Building \"${Z3_DOTNET_ASSEMBLY_DLL}\""
)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Microsoft.Z3.csproj.in ${CMAKE_CURRENT_BINARY_DIR}/build/Microsoft.Z3.csproj)
ADD_DOTNET(${CMAKE_CURRENT_BINARY_DIR}/build/Microsoft.Z3.csproj
VERSION ${Z3_DOTNET_NUPKG_VERSION}
PLATFORM ${Z3_DOTNET_PLATFORM}
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Microsoft.Z3.csproj.in
${CMAKE_CURRENT_SOURCE_DIR}/Microsoft.Z3.props
${CMAKE_CURRENT_SOURCE_DIR}/Microsoft.Z3.targets
${Z3_DOTNET_ASSEMBLY_SOURCES}
PACKAGE Microsoft.Z3
PACK_ARGUMENTS "/p:_DN_CMAKE_CONFIG=$<CONFIG>"
)
add_dependencies(BUILD_Microsoft.Z3 libz3)
# Convenient top-level target
add_custom_target(build_z3_dotnet_bindings
ALL
DEPENDS
"${Z3_DOTNET_ASSEMBLY_DLL}"
)
add_custom_target(build_z3_dotnet_bindings ALL DEPENDS BUILD_Microsoft.Z3)
# Register the local nupkg repo
set(Z3_DOTNET_LOCALREPO_NAME "Microsoft Z3 Local Repository")
DOTNET_REGISTER_LOCAL_REPOSITORY(${Z3_DOTNET_LOCALREPO_NAME} ${CMAKE_BINARY_DIR})
###############################################################################
# Install
# Install: register a local nuget repo and install our package.
# the build step depends on the 'purge' target, making sure that
# a user will always restore the freshly-built package.
###############################################################################
option(INSTALL_DOTNET_BINDINGS "Install .NET bindings when invoking install target" ON)
set(GAC_PKG_NAME "Microsoft.Z3.Sharp")
set(PREFIX "${CMAKE_INSTALL_PREFIX}")
set(VERSION "${Z3_VERSION}")
set(Z3_DOTNET_PKGCONFIG_FILE "${CMAKE_CURRENT_BINARY_DIR}/Microsoft.Z3.Sharp.pc")
configure_file("Microsoft.Z3.Sharp.pc.in" "${Z3_DOTNET_PKGCONFIG_FILE}" @ONLY)
if (DOTNET_TOOLCHAIN_IS_MONO)
message(STATUS "Emitting install rules for .NET bindings")
# Install pkgconfig file for the assembly. This is needed by Monodevelop
# to find the assembly
install(FILES "${Z3_DOTNET_PKGCONFIG_FILE}" DESTINATION "${CMAKE_INSTALL_PKGCONFIGDIR}")
# Configure the install and uninstall scripts.
# Note: If multi-configuration generator support is ever fixed then these
# scripts will be broken.
configure_file(cmake_install_gac.cmake.in cmake_install_gac.cmake @ONLY)
configure_file(cmake_uninstall_gac.cmake.in cmake_uninstall_gac.cmake @ONLY)
# Tell CMake to Invoke a script to install assembly to the GAC during install
install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/cmake_install_gac.cmake")
# Add custom target to uninstall the assembly from the GAC
add_custom_target(remove_dotnet_dll_from_gac
COMMAND "${CMAKE_COMMAND}" "-P" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall_gac.cmake"
COMMENT "Uninstalling ${Z3_DOTNET_ASSEMBLY_NAME} from the GAC"
${ADD_CUSTOM_COMMAND_USES_TERMINAL_ARG}
)
add_dependencies(uninstall remove_dotnet_dll_from_gac)
elseif(DOTNET_TOOLCHAIN_IS_WINDOWS)
# Don't install Z3_DOTNET_ASSEMBLY_DLL into the gac. Instead just copy into
# installation directory.
install(FILES "${Z3_DOTNET_ASSEMBLY_DLL}" DESTINATION "${CMAKE_INSTALL_LIBDIR}")
install(FILES "${Z3_DOTNET_ASSEMBLY_DLL_DOC}" DESTINATION "${CMAKE_INSTALL_LIBDIR}")
else()
message(FATAL_ERROR "Unknown .NET toolchain")
if(INSTALL_DOTNET_BINDINGS)
install(FILES "${CMAKE_BINARY_DIR}/Microsoft.Z3/Microsoft.Z3.${Z3_DOTNET_NUPKG_VERSION}.nupkg" DESTINATION "${CMAKE_INSTALL_LIBDIR}/z3.nuget")
# move the local repo to the installation directory (cancel the build-time repo)
install(CODE "include(${CMAKE_CURRENT_LIST_DIR}/../../../cmake/modules/FindDotnet.cmake)\n DOTNET_REGISTER_LOCAL_REPOSITORY(\"${Z3_DOTNET_LOCALREPO_NAME}\" ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/z3.nuget)")
install(FILES "${CMAKE_BINARY_DIR}/Microsoft.Z3/Microsoft.Z3.xml" DESTINATION "${CMAKE_INSTALL_LIBDIR}/z3.nuget")
# TODO GAC?
# set(GAC_PKG_NAME "Microsoft.Z3.Sharp")
# set(PREFIX "${CMAKE_INSTALL_PREFIX}")
# set(VERSION "${Z3_VERSION}")
endif()

View file

@ -475,7 +475,7 @@ namespace Microsoft.Z3
/// 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.
/// the remaining fields of t are unchanged.
/// </summary>
public Expr MkUpdateField(FuncDecl field, Expr t, Expr v)
{

View file

@ -144,7 +144,7 @@ namespace Microsoft.Z3
uint n = Size;
BoolExpr[] res = new BoolExpr[n];
for (uint i = 0; i < n; i++)
res[i] = new BoolExpr(Context, Native.Z3_goal_formula(Context.nCtx, NativeObject, i));
res[i] = (BoolExpr)Expr.Create(Context, Native.Z3_goal_formula(Context.nCtx, NativeObject, i));
return res;
}
}

View file

@ -76,7 +76,7 @@ namespace Microsoft.Z3
get
{
return new BoolExpr(Context, Native.Z3_get_quantifier_body(Context.nCtx, NativeObject));
return Expr.Create(Context, Native.Z3_get_quantifier_body(Context.nCtx, NativeObject));
}
}

View file

@ -1,418 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{EC3DB697-B734-42F7-9468-5B62821EEB5A}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Microsoft.Z3</RootNamespace>
<AssemblyName>Microsoft.Z3</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<CodeContractsAssemblyMode>0</CodeContractsAssemblyMode>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>..\Debug\Microsoft.Z3.XML</DocumentationFile>
<CodeContractsEnableRuntimeChecking>False</CodeContractsEnableRuntimeChecking>
<CodeContractsRuntimeOnlyPublicSurface>False</CodeContractsRuntimeOnlyPublicSurface>
<CodeContractsRuntimeThrowOnFailure>True</CodeContractsRuntimeThrowOnFailure>
<CodeContractsRuntimeCallSiteRequires>False</CodeContractsRuntimeCallSiteRequires>
<CodeContractsRuntimeSkipQuantifiers>False</CodeContractsRuntimeSkipQuantifiers>
<CodeContractsRunCodeAnalysis>True</CodeContractsRunCodeAnalysis>
<CodeContractsNonNullObligations>False</CodeContractsNonNullObligations>
<CodeContractsBoundsObligations>True</CodeContractsBoundsObligations>
<CodeContractsArithmeticObligations>True</CodeContractsArithmeticObligations>
<CodeContractsEnumObligations>False</CodeContractsEnumObligations>
<CodeContractsPointerObligations>False</CodeContractsPointerObligations>
<CodeContractsRedundantAssumptions>False</CodeContractsRedundantAssumptions>
<CodeContractsInferRequires>True</CodeContractsInferRequires>
<CodeContractsInferEnsures>False</CodeContractsInferEnsures>
<CodeContractsInferObjectInvariants>False</CodeContractsInferObjectInvariants>
<CodeContractsSuggestAssumptions>False</CodeContractsSuggestAssumptions>
<CodeContractsSuggestRequires>True</CodeContractsSuggestRequires>
<CodeContractsSuggestEnsures>False</CodeContractsSuggestEnsures>
<CodeContractsSuggestObjectInvariants>False</CodeContractsSuggestObjectInvariants>
<CodeContractsDisjunctiveRequires>True</CodeContractsDisjunctiveRequires>
<CodeContractsRunInBackground>True</CodeContractsRunInBackground>
<CodeContractsShowSquigglies>True</CodeContractsShowSquigglies>
<CodeContractsUseBaseLine>False</CodeContractsUseBaseLine>
<CodeContractsEmitXMLDocs>False</CodeContractsEmitXMLDocs>
<CodeContractsCustomRewriterAssembly />
<CodeContractsCustomRewriterClass />
<CodeContractsLibPaths />
<CodeContractsExtraRewriteOptions />
<CodeContractsExtraAnalysisOptions />
<CodeContractsBaseLineFile />
<CodeContractsCacheAnalysisResults>True</CodeContractsCacheAnalysisResults>
<CodeContractsRuntimeCheckingLevel>Full</CodeContractsRuntimeCheckingLevel>
<CodeContractsReferenceAssembly>%28none%29</CodeContractsReferenceAssembly>
<CodeContractsAnalysisWarningLevel>2</CodeContractsAnalysisWarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\external\</OutputPath>
<DefineConstants>
</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>..\external\Microsoft.Z3.xml</DocumentationFile>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'external|AnyCPU' ">
<OutputPath>..\external\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>..\external\Microsoft.Z3.xml</DocumentationFile>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<CodeAnalysisLogFile>bin\Release\Microsoft.Z3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSetDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisRuleDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>..\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<CodeAnalysisLogFile>..\Debug\Microsoft.Z3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
<CodeContractsEnableRuntimeChecking>True</CodeContractsEnableRuntimeChecking>
<CodeContractsRuntimeOnlyPublicSurface>False</CodeContractsRuntimeOnlyPublicSurface>
<CodeContractsRuntimeThrowOnFailure>True</CodeContractsRuntimeThrowOnFailure>
<CodeContractsRuntimeCallSiteRequires>False</CodeContractsRuntimeCallSiteRequires>
<CodeContractsRuntimeSkipQuantifiers>False</CodeContractsRuntimeSkipQuantifiers>
<CodeContractsRunCodeAnalysis>False</CodeContractsRunCodeAnalysis>
<CodeContractsNonNullObligations>False</CodeContractsNonNullObligations>
<CodeContractsBoundsObligations>False</CodeContractsBoundsObligations>
<CodeContractsArithmeticObligations>False</CodeContractsArithmeticObligations>
<CodeContractsEnumObligations>False</CodeContractsEnumObligations>
<CodeContractsPointerObligations>False</CodeContractsPointerObligations>
<CodeContractsRedundantAssumptions>False</CodeContractsRedundantAssumptions>
<CodeContractsInferRequires>False</CodeContractsInferRequires>
<CodeContractsInferEnsures>False</CodeContractsInferEnsures>
<CodeContractsInferObjectInvariants>False</CodeContractsInferObjectInvariants>
<CodeContractsSuggestAssumptions>False</CodeContractsSuggestAssumptions>
<CodeContractsSuggestRequires>True</CodeContractsSuggestRequires>
<CodeContractsSuggestEnsures>False</CodeContractsSuggestEnsures>
<CodeContractsSuggestObjectInvariants>False</CodeContractsSuggestObjectInvariants>
<CodeContractsRunInBackground>True</CodeContractsRunInBackground>
<CodeContractsShowSquigglies>False</CodeContractsShowSquigglies>
<CodeContractsUseBaseLine>False</CodeContractsUseBaseLine>
<CodeContractsEmitXMLDocs>False</CodeContractsEmitXMLDocs>
<CodeContractsCustomRewriterAssembly />
<CodeContractsCustomRewriterClass />
<CodeContractsLibPaths />
<CodeContractsExtraRewriteOptions />
<CodeContractsExtraAnalysisOptions />
<CodeContractsBaseLineFile />
<CodeContractsCacheAnalysisResults>False</CodeContractsCacheAnalysisResults>
<CodeContractsRuntimeCheckingLevel>Full</CodeContractsRuntimeCheckingLevel>
<CodeContractsReferenceAssembly>%28none%29</CodeContractsReferenceAssembly>
<CodeContractsAnalysisWarningLevel>0</CodeContractsAnalysisWarningLevel>
<DocumentationFile>..\x64\Debug\Microsoft.Z3.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>..\x64\external_64\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>..\x64\external_64\Microsoft.Z3.xml</DocumentationFile>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<CodeAnalysisLogFile>..\release\Microsoft.Z3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
<CodeContractsEnableRuntimeChecking>True</CodeContractsEnableRuntimeChecking>
<CodeContractsRuntimeOnlyPublicSurface>False</CodeContractsRuntimeOnlyPublicSurface>
<CodeContractsRuntimeThrowOnFailure>True</CodeContractsRuntimeThrowOnFailure>
<CodeContractsRuntimeCallSiteRequires>False</CodeContractsRuntimeCallSiteRequires>
<CodeContractsRuntimeSkipQuantifiers>False</CodeContractsRuntimeSkipQuantifiers>
<CodeContractsRunCodeAnalysis>True</CodeContractsRunCodeAnalysis>
<CodeContractsNonNullObligations>True</CodeContractsNonNullObligations>
<CodeContractsBoundsObligations>True</CodeContractsBoundsObligations>
<CodeContractsArithmeticObligations>False</CodeContractsArithmeticObligations>
<CodeContractsEnumObligations>False</CodeContractsEnumObligations>
<CodeContractsPointerObligations>False</CodeContractsPointerObligations>
<CodeContractsRedundantAssumptions>True</CodeContractsRedundantAssumptions>
<CodeContractsInferRequires>True</CodeContractsInferRequires>
<CodeContractsInferEnsures>False</CodeContractsInferEnsures>
<CodeContractsInferObjectInvariants>False</CodeContractsInferObjectInvariants>
<CodeContractsSuggestAssumptions>False</CodeContractsSuggestAssumptions>
<CodeContractsSuggestRequires>True</CodeContractsSuggestRequires>
<CodeContractsSuggestEnsures>False</CodeContractsSuggestEnsures>
<CodeContractsSuggestObjectInvariants>False</CodeContractsSuggestObjectInvariants>
<CodeContractsRunInBackground>True</CodeContractsRunInBackground>
<CodeContractsShowSquigglies>True</CodeContractsShowSquigglies>
<CodeContractsUseBaseLine>False</CodeContractsUseBaseLine>
<CodeContractsEmitXMLDocs>False</CodeContractsEmitXMLDocs>
<CodeContractsCustomRewriterAssembly />
<CodeContractsCustomRewriterClass />
<CodeContractsLibPaths />
<CodeContractsExtraRewriteOptions />
<CodeContractsExtraAnalysisOptions>-repro</CodeContractsExtraAnalysisOptions>
<CodeContractsBaseLineFile />
<CodeContractsCacheAnalysisResults>True</CodeContractsCacheAnalysisResults>
<CodeContractsRuntimeCheckingLevel>Full</CodeContractsRuntimeCheckingLevel>
<CodeContractsReferenceAssembly>%28none%29</CodeContractsReferenceAssembly>
<CodeContractsAnalysisWarningLevel>2</CodeContractsAnalysisWarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'external|x64'">
<OutputPath>..\x64\external\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>..\x64\external\Microsoft.Z3.XML</DocumentationFile>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<CodeAnalysisLogFile>bin\Release\Microsoft.Z3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSetDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisRuleDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>false</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup>
<DelaySign>false</DelaySign>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release_delaysign|AnyCPU'">
<OutputPath>..\Release_delaysign\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>..\Release_delaysign\Microsoft.Z3.XML</DocumentationFile>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<CodeAnalysisLogFile>..\release\Microsoft.Z3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSetDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisRuleDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
<DefineConstants>DELAYSIGN</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release_delaysign|x64'">
<OutputPath>bin\x64\Release_delaysign\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>bin\x64\Release_delaysign\Microsoft.Z3.XML</DocumentationFile>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<CodeAnalysisLogFile>..\release\Microsoft.Z3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>..\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<CodeAnalysisLogFile>..\Debug\Microsoft.Z3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
<DocumentationFile>..\x86\Debug\Microsoft.Z3.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>bin\x86\Release\Microsoft.Z3.xml</DocumentationFile>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<CodeAnalysisLogFile>..\external\Microsoft.Z3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'external|x86'">
<OutputPath>bin\x86\external\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>bin\x86\external\Microsoft.Z3.XML</DocumentationFile>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<CodeAnalysisLogFile>bin\Release\Microsoft.Z3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSetDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisRuleDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release_delaysign|x86'">
<OutputPath>bin\x86\Release_delaysign\</OutputPath>
<DefineConstants>DELAYSIGN</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>bin\x86\Release_delaysign\Microsoft.Z3.XML</DocumentationFile>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<CodeAnalysisLogFile>..\release\Microsoft.Z3.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSetDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
<CodeAnalysisIgnoreBuiltInRuleSets>true</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisRuleDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
</ItemGroup>
<ItemGroup>
<Compile Include="AlgebraicNum.cs" />
<Compile Include="ApplyResult.cs" />
<Compile Include="ArithExpr.cs" />
<Compile Include="ArithSort.cs" />
<Compile Include="ArrayExpr.cs" />
<Compile Include="ArraySort.cs" />
<Compile Include="AST.cs" />
<Compile Include="ASTMap.cs" />
<Compile Include="ASTVector.cs" />
<Compile Include="BitVecExpr.cs" />
<Compile Include="BitVecNum.cs" />
<Compile Include="BitVecSort.cs" />
<Compile Include="BoolExpr.cs" />
<Compile Include="BoolSort.cs" />
<Compile Include="Constructor.cs" />
<Compile Include="ConstructorList.cs" />
<Compile Include="DatatypeExpr.cs" />
<Compile Include="DatatypeSort.cs" />
<Compile Include="Deprecated.cs" />
<Compile Include="FiniteDomainExpr.cs" />
<Compile Include="FiniteDomainNum.cs" />
<Compile Include="FPExpr.cs" />
<Compile Include="FPNum.cs" />
<Compile Include="FPRMExpr.cs" />
<Compile Include="FPRMNum.cs" />
<Compile Include="FPRMSort.cs" />
<Compile Include="FPSort.cs" />
<Compile Include="Global.cs" />
<Compile Include="IDecRefQueue.cs" />
<Compile Include="Enumerations.cs" />
<Compile Include="EnumSort.cs" />
<Compile Include="Expr.cs" />
<Compile Include="FiniteDomainSort.cs" />
<Compile Include="Fixedpoint.cs" />
<Compile Include="FuncDecl.cs" />
<Compile Include="FuncInterp.cs" />
<Compile Include="Goal.cs" />
<Compile Include="IntExpr.cs" />
<Compile Include="IntNum.cs" />
<Compile Include="IntSort.cs" />
<Compile Include="IntSymbol.cs" />
<Compile Include="Lambda.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" />
<Compile Include="RatNum.cs" />
<Compile Include="RealExpr.cs" />
<Compile Include="RealSort.cs" />
<Compile Include="ReExpr.cs" />
<Compile Include="RelationSort.cs" />
<Compile Include="ReSort.cs" />
<Compile Include="SeqExpr.cs" />
<Compile Include="SeqSort.cs" />
<Compile Include="SetSort.cs" />
<Compile Include="Statistics.cs" />
<Compile Include="Status.cs" />
<Compile Include="Context.cs" />
<Compile Include="Probe.cs" />
<Compile Include="Solver.cs" />
<Compile Include="StringSymbol.cs" />
<Compile Include="Tactic.cs" />
<Compile Include="TupleSort.cs" />
<Compile Include="UninterpretedSort.cs" />
<Compile Include="Z3Exception.cs" />
<Compile Include="Log.cs" />
<Compile Include="Native.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Quantifier.cs" />
<Compile Include="Sort.cs" />
<Compile Include="Symbol.cs" />
<Compile Include="Version.cs" />
<Compile Include="Z3Object.cs" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Service References\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View file

@ -0,0 +1,95 @@
<Project Sdk="Microsoft.NET.Sdk">
<!-- Package metadata properties -->
<PropertyGroup>
<PackageId>Microsoft.Z3</PackageId>
<AssemblyName>Microsoft.Z3</AssemblyName>
<RootNamespace>Microsoft.Z3</RootNamespace>
<Title>Z3 .NET Interface</Title>
<AssemblyTitle>Z3 .NET Interface</AssemblyTitle>
<AssemblyProduct>Z3</AssemblyProduct>
<Description>Z3 is a satisfiability modulo theories solver from Microsoft Research.</Description>
<AssemblyDescription>.NET Interface to the Z3 Theorem Prover</AssemblyDescription>
<Copyright>Copyright (C) 2006-2019 Microsoft Corporation</Copyright>
<AssemblyCopyright>Copyright (C) 2006-2019 Microsoft Corporation</AssemblyCopyright>
<Company>Microsoft Corporation</Company>
<AssemblyCompany>Microsoft Corporation</AssemblyCompany>
<Version>@VER_MAJOR@.@VER_MINOR@.@VER_BUILD@.@VER_REVISION@</Version>
<AssemblyVersion>@VER_MAJOR@.@VER_MINOR@.@VER_BUILD@.@VER_REVISION@</AssemblyVersion>
<FileVersion>@VER_MAJOR@.@VER_MINOR@.@VER_BUILD@.@VER_REVISION@</FileVersion>
<AssemblyFileVersion>@VER_MAJOR@.@VER_MINOR@.@VER_BUILD@.@VER_REVISION@</AssemblyFileVersion>
<PackageVersion>${DOTNET_PACKAGE_VERSION}</PackageVersion>
<PackageTags>smt constraint solver theorem prover</PackageTags>
<Authors>Microsoft</Authors>
<Company>Microsoft</Company>
</PropertyGroup>
<!-- Code contract & signing properties -->
<PropertyGroup Condition="'$(Configuration)' != 'Release_delaysign'">
<SignAssembly>false</SignAssembly>
<DelaySign>false</DelaySign>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release_delaysign'">
<DefineConstants>DELAYSIGN</DefineConstants>
<SignAssembly>true</SignAssembly>
<DelaySign>true</DelaySign>
</PropertyGroup>
<!-- Build properties -->
<PropertyGroup>
<!-- In *nix builds, netfx TFMs are not available. -->
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
<OutputTypeEx>library</OutputTypeEx>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<NoWarn>1701,1702</NoWarn>
<Warn>4</Warn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<DocumentationFile>$(OutputPath)\Microsoft.Z3.xml</DocumentationFile>
</PropertyGroup>
<!-- Compilation items -->
<ItemGroup>
${Z3_DOTNET_COMPILE_ITEMS}
</ItemGroup>
<!-- Legacy .NET framework native library helper routines -->
<ItemGroup>
<Content Include="${CMAKE_CURRENT_LIST_DIR}/Microsoft.Z3.props">
<PackagePath>build</PackagePath>
</Content>
<Content Include="${CMAKE_CURRENT_LIST_DIR}/Microsoft.Z3.targets">
<PackagePath>build</PackagePath>
</Content>
</ItemGroup>
<!-- TODO we may want to pack x64 and x86 native assemblies into a single nupkg -->
<!-- Native binaries x64 -->
<ItemGroup Condition="'$(Platform)' != 'x86'">
<Content Include="${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/$(_DN_CMAKE_CONFIG)/libz3.dll" Condition="Exists('${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/$(_DN_CMAKE_CONFIG)/libz3.dll')">
<PackagePath>runtimes\win-x64\native</PackagePath>
</Content>
<Content Include="${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libz3.so" Condition="Exists('${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libz3.so')">
<PackagePath>runtimes\linux-x64\native</PackagePath>
</Content>
</ItemGroup>
<!-- Native binaries for x86; currently only Windows is supported. -->
<ItemGroup Condition="'$(Platform)' == 'x86'">
<Content Include="${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/$(_DN_CMAKE_CONFIG)/libz3.dll" Condition="Exists('${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/$(_DN_CMAKE_CONFIG)/libz3.dll')">
<PackagePath>runtimes\win-x86\native</PackagePath>
</Content>
</ItemGroup>
</Project>

View file

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Paths -->
<PropertyGroup>
<IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</IsOSX>
<IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinux>
<IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows>
<!-- Probe the package root path -->
<Z3_PACKAGE_PATH Condition="('$(Z3_PACKAGE_PATH)' == '')">$(MSBuildThisFileDirectory)..\</Z3_PACKAGE_PATH>
<Z3_NATIVE_LIB_PATH Condition="'$(IsWindows)' == 'true' and '$(Platform)' != 'x86'">$(Z3_PACKAGE_PATH)runtimes\win-x64\native\libz3.dll</Z3_NATIVE_LIB_PATH>
<Z3_NATIVE_LIB_PATH Condition="'$(IsWindows)' == 'true' and '$(Platform)' == 'x86'">$(Z3_PACKAGE_PATH)runtimes\win-x86\native\libz3.dll</Z3_NATIVE_LIB_PATH>
<Z3_NATIVE_LIB_PATH Condition="'$(IsLinux)' == 'true'">$(Z3_PACKAGE_PATH)runtimes\linux-x64\native\libz3.so</Z3_NATIVE_LIB_PATH>
</PropertyGroup>
<!-- Configurations -->
<PropertyGroup>
<!-- Disable "prefer 32-bit mode", so that the program runs in 64 bit mode and loads libz3 correctly. -->
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
</Project>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Condition="!$(TargetFramework.Contains('netstandard')) and !$(TargetFramework.Contains('netcoreapp'))">
<None Include="$(Z3_NATIVE_LIB_PATH)">
<Link>%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View file

@ -25,7 +25,7 @@ using System.Linq;
namespace Microsoft.Z3
{
/// <summary>
/// Object for managing optimizization context
/// Object for managing optimization context
/// </summary>
public class Optimize : Z3Object
{

View file

@ -148,7 +148,7 @@ namespace Microsoft.Z3
get
{
return new BoolExpr(Context, Native.Z3_get_quantifier_body(Context.nCtx, NativeObject));
return (BoolExpr)Expr.Create(Context, Native.Z3_get_quantifier_body(Context.nCtx, NativeObject));
}
}

View file

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

View file

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

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>

View file

@ -1,78 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Example</RootNamespace>
<AssemblyName>Example</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;FRAMEWORK_LT_4</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;FRAMEWORK_LT_4</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;FRAMEWORK_LT_4</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE;FRAMEWORK_LT_4</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\..\..\..\examples\dotnet\Program.cs">
<Link>Program.cs</Link>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.Z3.NET35.csproj">
<Project>{ec3db697-b734-42f7-9468-5b62821eeb5a}</Project>
<Name>Microsoft.Z3.NET35</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View file

@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Example")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Example")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("2a8e577b-7b6d-4ca9-832a-ca2eec314812")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -1,347 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{EC3DB697-B734-42F7-9468-5B62821EEB5A}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Microsoft.Z3</RootNamespace>
<AssemblyName>Microsoft.Z3</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<CodeContractsAssemblyMode>0</CodeContractsAssemblyMode>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;FRAMEWORK_LT_4</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>Debug\Microsoft.Z3.XML</DocumentationFile>
<CodeContractsEnableRuntimeChecking>False</CodeContractsEnableRuntimeChecking>
<CodeContractsRuntimeOnlyPublicSurface>False</CodeContractsRuntimeOnlyPublicSurface>
<CodeContractsRuntimeThrowOnFailure>True</CodeContractsRuntimeThrowOnFailure>
<CodeContractsRuntimeCallSiteRequires>False</CodeContractsRuntimeCallSiteRequires>
<CodeContractsRuntimeSkipQuantifiers>False</CodeContractsRuntimeSkipQuantifiers>
<CodeContractsRunCodeAnalysis>True</CodeContractsRunCodeAnalysis>
<CodeContractsNonNullObligations>False</CodeContractsNonNullObligations>
<CodeContractsBoundsObligations>True</CodeContractsBoundsObligations>
<CodeContractsArithmeticObligations>True</CodeContractsArithmeticObligations>
<CodeContractsEnumObligations>False</CodeContractsEnumObligations>
<CodeContractsPointerObligations>False</CodeContractsPointerObligations>
<CodeContractsRedundantAssumptions>False</CodeContractsRedundantAssumptions>
<CodeContractsInferRequires>True</CodeContractsInferRequires>
<CodeContractsInferEnsures>False</CodeContractsInferEnsures>
<CodeContractsInferObjectInvariants>False</CodeContractsInferObjectInvariants>
<CodeContractsSuggestAssumptions>False</CodeContractsSuggestAssumptions>
<CodeContractsSuggestRequires>True</CodeContractsSuggestRequires>
<CodeContractsSuggestEnsures>False</CodeContractsSuggestEnsures>
<CodeContractsSuggestObjectInvariants>False</CodeContractsSuggestObjectInvariants>
<CodeContractsDisjunctiveRequires>True</CodeContractsDisjunctiveRequires>
<CodeContractsRunInBackground>True</CodeContractsRunInBackground>
<CodeContractsShowSquigglies>True</CodeContractsShowSquigglies>
<CodeContractsUseBaseLine>False</CodeContractsUseBaseLine>
<CodeContractsEmitXMLDocs>False</CodeContractsEmitXMLDocs>
<CodeContractsCustomRewriterAssembly />
<CodeContractsCustomRewriterClass />
<CodeContractsLibPaths />
<CodeContractsExtraRewriteOptions />
<CodeContractsExtraAnalysisOptions />
<CodeContractsBaseLineFile />
<CodeContractsCacheAnalysisResults>True</CodeContractsCacheAnalysisResults>
<CodeContractsRuntimeCheckingLevel>Full</CodeContractsRuntimeCheckingLevel>
<CodeContractsReferenceAssembly>%28none%29</CodeContractsReferenceAssembly>
<CodeContractsAnalysisWarningLevel>2</CodeContractsAnalysisWarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>Release\</OutputPath>
<DefineConstants>FRAMEWORK_LT_4</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>Release\Microsoft.Z3.xml</DocumentationFile>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup>
<DelaySign>false</DelaySign>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;FRAMEWORK_LT_4</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>Debug\Microsoft.Z3.XML</DocumentationFile>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>FRAMEWORK_LT_4</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DocumentationFile>Release\Microsoft.Z3.xml</DocumentationFile>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=736440c9b414ea16, processorArchitecture=MSIL">
<HintPath>packages\Code.Contract.1.0.0\lib\net35\Microsoft.Contracts.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\AlgebraicNum.cs">
<Link>AlgebraicNum.cs</Link>
</Compile>
<Compile Include="..\ApplyResult.cs">
<Link>ApplyResult.cs</Link>
</Compile>
<Compile Include="..\ArithExpr.cs">
<Link>ArithExpr.cs</Link>
</Compile>
<Compile Include="..\ArithSort.cs">
<Link>ArithSort.cs</Link>
</Compile>
<Compile Include="..\ArrayExpr.cs">
<Link>ArrayExpr.cs</Link>
</Compile>
<Compile Include="..\ArraySort.cs">
<Link>ArraySort.cs</Link>
</Compile>
<Compile Include="..\AST.cs">
<Link>AST.cs</Link>
</Compile>
<Compile Include="..\ASTMap.cs">
<Link>ASTMap.cs</Link>
</Compile>
<Compile Include="..\ASTVector.cs">
<Link>ASTVector.cs</Link>
</Compile>
<Compile Include="..\BitVecExpr.cs">
<Link>BitVecExpr.cs</Link>
</Compile>
<Compile Include="..\BitVecNum.cs">
<Link>BitVecNum.cs</Link>
</Compile>
<Compile Include="..\BitVecSort.cs">
<Link>BitVecSort.cs</Link>
</Compile>
<Compile Include="..\BoolExpr.cs">
<Link>BoolExpr.cs</Link>
</Compile>
<Compile Include="..\BoolSort.cs">
<Link>BoolSort.cs</Link>
</Compile>
<Compile Include="..\Constructor.cs">
<Link>Constructor.cs</Link>
</Compile>
<Compile Include="..\ConstructorList.cs">
<Link>ConstructorList.cs</Link>
</Compile>
<Compile Include="..\Context.cs">
<Link>Context.cs</Link>
</Compile>
<Compile Include="..\DatatypeExpr.cs">
<Link>DatatypeExpr.cs</Link>
</Compile>
<Compile Include="..\DatatypeSort.cs">
<Link>DatatypeSort.cs</Link>
</Compile>
<Compile Include="..\Deprecated.cs">
<Link>Deprecated.cs</Link>
</Compile>
<Compile Include="..\Enumerations.cs">
<Link>Enumerations.cs</Link>
</Compile>
<Compile Include="..\EnumSort.cs">
<Link>EnumSort.cs</Link>
</Compile>
<Compile Include="..\Expr.cs">
<Link>Expr.cs</Link>
</Compile>
<Compile Include="..\FiniteDomainExpr.cs">
<Link>FiniteDomainExpr.cs</Link>
</Compile>
<Compile Include="..\FiniteDomainNum.cs">
<Link>FiniteDomainNum.cs</Link>
</Compile>
<Compile Include="..\FiniteDomainSort.cs">
<Link>FiniteDomainSort.cs</Link>
</Compile>
<Compile Include="..\Fixedpoint.cs">
<Link>Fixedpoint.cs</Link>
</Compile>
<Compile Include="..\FPExpr.cs">
<Link>FPExpr.cs</Link>
</Compile>
<Compile Include="..\FPNum.cs">
<Link>FPNum.cs</Link>
</Compile>
<Compile Include="..\FPRMExpr.cs">
<Link>FPRMExpr.cs</Link>
</Compile>
<Compile Include="..\FPRMNum.cs">
<Link>FPRMNum.cs</Link>
</Compile>
<Compile Include="..\FPRMSort.cs">
<Link>FPRMSort.cs</Link>
</Compile>
<Compile Include="..\FPSort.cs">
<Link>FPSort.cs</Link>
</Compile>
<Compile Include="..\FuncDecl.cs">
<Link>FuncDecl.cs</Link>
</Compile>
<Compile Include="..\FuncInterp.cs">
<Link>FuncInterp.cs</Link>
</Compile>
<Compile Include="..\Global.cs">
<Link>Global.cs</Link>
</Compile>
<Compile Include="..\Goal.cs">
<Link>Goal.cs</Link>
</Compile>
<Compile Include="..\IDecRefQueue.cs">
<Link>IDecRefQueue.cs</Link>
</Compile>
<Compile Include="..\InterpolationContext.cs">
<Link>InterpolationContext.cs</Link>
</Compile>
<Compile Include="..\IntExpr.cs">
<Link>IntExpr.cs</Link>
</Compile>
<Compile Include="..\IntNum.cs">
<Link>IntNum.cs</Link>
</Compile>
<Compile Include="..\IntSort.cs">
<Link>IntSort.cs</Link>
</Compile>
<Compile Include="..\IntSymbol.cs">
<Link>IntSymbol.cs</Link>
</Compile>
<Compile Include="..\ListSort.cs">
<Link>ListSort.cs</Link>
</Compile>
<Compile Include="..\Log.cs">
<Link>Log.cs</Link>
</Compile>
<Compile Include="..\Model.cs">
<Link>Model.cs</Link>
</Compile>
<Compile Include="..\Native.cs">
<Link>Native.cs</Link>
</Compile>
<Compile Include="..\Optimize.cs">
<Link>Optimize.cs</Link>
</Compile>
<Compile Include="..\ParamDescrs.cs">
<Link>ParamDescrs.cs</Link>
</Compile>
<Compile Include="..\Params.cs">
<Link>Params.cs</Link>
</Compile>
<Compile Include="..\Pattern.cs">
<Link>Pattern.cs</Link>
</Compile>
<Compile Include="..\Probe.cs">
<Link>Probe.cs</Link>
</Compile>
<Compile Include="..\Quantifier.cs">
<Link>Quantifier.cs</Link>
</Compile>
<Compile Include="..\RatNum.cs">
<Link>RatNum.cs</Link>
</Compile>
<Compile Include="..\RealExpr.cs">
<Link>RealExpr.cs</Link>
</Compile>
<Compile Include="..\RealSort.cs">
<Link>RealSort.cs</Link>
</Compile>
<Compile Include="..\ReExpr.cs">
<Link>ReExpr.cs</Link>
</Compile>
<Compile Include="..\RelationSort.cs">
<Link>RelationSort.cs</Link>
</Compile>
<Compile Include="..\ReSort.cs">
<Link>ReSort.cs</Link>
</Compile>
<Compile Include="..\SeqExpr.cs">
<Link>SeqExpr.cs</Link>
</Compile>
<Compile Include="..\SeqSort.cs">
<Link>SeqSort.cs</Link>
</Compile>
<Compile Include="..\SetSort.cs">
<Link>SetSort.cs</Link>
</Compile>
<Compile Include="..\Solver.cs">
<Link>Solver.cs</Link>
</Compile>
<Compile Include="..\Sort.cs">
<Link>Sort.cs</Link>
</Compile>
<Compile Include="..\Statistics.cs">
<Link>Statistics.cs</Link>
</Compile>
<Compile Include="..\Status.cs">
<Link>Status.cs</Link>
</Compile>
<Compile Include="..\StringSymbol.cs">
<Link>StringSymbol.cs</Link>
</Compile>
<Compile Include="..\Symbol.cs">
<Link>Symbol.cs</Link>
</Compile>
<Compile Include="..\Tactic.cs">
<Link>Tactic.cs</Link>
</Compile>
<Compile Include="..\TupleSort.cs">
<Link>TupleSort.cs</Link>
</Compile>
<Compile Include="..\UninterpretedSort.cs">
<Link>UninterpretedSort.cs</Link>
</Compile>
<Compile Include="..\Version.cs">
<Link>Version.cs</Link>
</Compile>
<Compile Include="..\Z3Exception.cs">
<Link>Z3Exception.cs</Link>
</Compile>
<Compile Include="..\Z3Object.cs">
<Link>Z3Object.cs</Link>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Service References\" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View file

@ -1,48 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Z3.NET35", "Microsoft.Z3.NET35.csproj", "{EC3DB697-B734-42F7-9468-5B62821EEB5A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example", "Example\Example.csproj", "{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Debug|x64.ActiveCfg = Debug|Any CPU
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Debug|x64.Build.0 = Debug|Any CPU
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Debug|x86.ActiveCfg = Debug|Any CPU
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Debug|x86.Build.0 = Debug|Any CPU
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Release|Any CPU.Build.0 = Release|Any CPU
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Release|x64.ActiveCfg = Release|x64
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Release|x64.Build.0 = Release|x64
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Release|x86.ActiveCfg = Release|Any CPU
{EC3DB697-B734-42F7-9468-5B62821EEB5A}.Release|x86.Build.0 = Release|Any CPU
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Debug|x64.ActiveCfg = Debug|Any CPU
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Debug|x64.Build.0 = Debug|Any CPU
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Debug|x86.ActiveCfg = Debug|Any CPU
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Debug|x86.Build.0 = Debug|Any CPU
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Release|Any CPU.Build.0 = Release|Any CPU
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Release|x64.ActiveCfg = Release|x64
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Release|x64.Build.0 = Release|x64
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Release|x86.ActiveCfg = Release|Any CPU
{2A8E577B-7B6D-4CA9-832A-CA2EEC314812}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View file

@ -1,38 +0,0 @@
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security.Permissions;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Z3 .NET Interface")]
[assembly: AssemblyDescription(".NET Interface to the Z3 Theorem Prover")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyProduct("Z3")]
[assembly: AssemblyCopyright("Copyright (C) 2006-2015 Microsoft Corporation")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("4853ed71-2078-40f4-8117-bc46646bce0e")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("4.2.0.0")]
[assembly: AssemblyVersion("4.5.1.6031")]
[assembly: AssemblyFileVersion("4.5.1.6031")]

View file

@ -1,38 +0,0 @@
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security.Permissions;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Z3 .NET Interface")]
[assembly: AssemblyDescription(".NET Interface to the Z3 Theorem Prover")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyProduct("Z3")]
[assembly: AssemblyCopyright("Copyright (C) 2006-2015 Microsoft Corporation")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("4853ed71-2078-40f4-8117-bc46646bce0e")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("4.2.0.0")]
[assembly: AssemblyVersion("@VER_MAJOR@.@VER_MINOR@.@VER_BUILD@.@VER_REVISION@")]
[assembly: AssemblyFileVersion("@VER_MAJOR@.@VER_MINOR@.@VER_BUILD@.@VER_REVISION@")]

View file

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

View file

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Code.Contract" version="1.0.0" targetFramework="net35" />
</packages>

View file

@ -39,8 +39,7 @@ add_library(z3java SHARED ${Z3_JAVA_NATIVE_CPP})
target_link_libraries(z3java PRIVATE libz3)
# FIXME:
# Not sure if using all the flags used by the Z3 components is really necessary
# here. At the bare minimum setting _AMD64_ depending on the target is
# necessary but seeing as the Python build system uses all the flags used for building
# here. The Python build system uses all the flags used for building
# Z3's components to build ``Native.cpp`` lets do the same for now.
target_compile_options(z3java PRIVATE ${Z3_COMPONENT_CXX_FLAGS})
target_compile_definitions(z3java PRIVATE ${Z3_COMPONENT_CXX_DEFINES})

View file

@ -3356,7 +3356,7 @@ public class Context implements AutoCloseable {
}
/**
* Create a numeral of FloatingPoint sort from a float.
* Create a numeral of FloatingPoint sort from a double.
* @param v numeral value.
* @param s FloatingPoint sort.
* @throws Z3Exception
@ -3368,7 +3368,7 @@ public class Context implements AutoCloseable {
/**
* Create a numeral of FloatingPoint sort from an int.
* * @param v numeral value.
* @param v numeral value.
* @param s FloatingPoint sort.
* @throws Z3Exception
**/
@ -3380,8 +3380,8 @@ public class Context implements AutoCloseable {
/**
* Create a numeral of FloatingPoint sort from a sign bit and two integers.
* @param sgn the sign.
* @param sig the significand.
* @param exp the exponent.
* @param sig the significand.
* @param s FloatingPoint sort.
* @throws Z3Exception
**/
@ -3393,8 +3393,8 @@ public class Context implements AutoCloseable {
/**
* Create a numeral of FloatingPoint sort from a sign bit and two 64-bit integers.
* @param sgn the sign.
* @param sig the significand.
* @param exp the exponent.
* @param sig the significand.
* @param s FloatingPoint sort.
* @throws Z3Exception
**/
@ -3415,7 +3415,7 @@ public class Context implements AutoCloseable {
}
/**
* Create a numeral of FloatingPoint sort from a float.
* Create a numeral of FloatingPoint sort from a double.
* @param v numeral value.
* @param s FloatingPoint sort.
* @throws Z3Exception
@ -3447,7 +3447,7 @@ public class Context implements AutoCloseable {
**/
public FPNum mkFP(boolean sgn, int exp, int sig, FPSort s)
{
return mkFPNumeral(sgn, sig, exp, s);
return mkFPNumeral(sgn, exp, sig, s);
}
/**
@ -3460,7 +3460,7 @@ public class Context implements AutoCloseable {
**/
public FPNum mkFP(boolean sgn, long exp, long sig, FPSort s)
{
return mkFPNumeral(sgn, sig, exp, s);
return mkFPNumeral(sgn, exp, sig, s);
}

View file

@ -130,8 +130,7 @@ public class Goal extends Z3Object {
int n = size();
BoolExpr[] res = new BoolExpr[n];
for (int i = 0; i < n; i++)
res[i] = new BoolExpr(getContext(), Native.goalFormula(getContext()
.nCtx(), getNativeObject(), i));
res[i] = (BoolExpr) Expr.create(getContext(), Native.goalFormula(getContext().nCtx(), getNativeObject(), i));
return res;
}

View file

@ -70,9 +70,9 @@ import com.microsoft.z3.enumerations.Z3_ast_kind;
*
* @throws Z3Exception
**/
public BoolExpr getBody()
public Expr getBody()
{
return new BoolExpr(getContext(), Native.getQuantifierBody(getContext()
return Expr.create(getContext(), Native.getQuantifierBody(getContext()
.nCtx(), getNativeObject()));
}

View file

@ -141,7 +141,7 @@ public class Quantifier extends BoolExpr
**/
public BoolExpr getBody()
{
return new BoolExpr(getContext(), Native.getQuantifierBody(getContext()
return (BoolExpr) Expr.create(getContext(), Native.getQuantifierBody(getContext()
.nCtx(), getNativeObject()));
}

View file

@ -2023,3 +2023,7 @@ let toggle_warning_messages = Z3native.toggle_warning_messages
let enable_trace = Z3native.enable_trace
let disable_trace = Z3native.enable_trace
module Memory = struct
let reset = Z3native.reset_memory
end

View file

@ -3472,3 +3472,11 @@ val enable_trace : string -> unit
Remarks: It is a NOOP otherwise.
*)
val disable_trace : string -> unit
(** Memory management **)
module Memory :
sig
(** Reset all allocated resources **)
val reset : unit -> unit
end

View file

@ -448,3 +448,21 @@ CAMLprim value DLL_PUBLIC n_set_internal_error_handler(value ctx_v)
Z3_set_error_handler(ctx_p->ctx, MLErrorHandler);
CAMLreturn(Val_unit);
}
CAMLprim DLL_PUBLIC value n_mk_config() {
CAMLparam0();
CAMLlocal1(result);
Z3_config z3rv;
/* invoke Z3 function */
z3rv = Z3_mk_config();
if (z3rv == NULL) {
caml_raise_with_string(*caml_named_value("Z3EXCEPTION"), "Object allocation failed");
}
/* construct simple return value */
result = caml_alloc_custom(&default_custom_ops, sizeof(Z3_config), 0, 1); *(Z3_config*)Data_custom_val(result) = z3rv;
/* cleanup and return */
CAMLreturn(result);
}

View file

@ -1,8 +1,4 @@
You can learn more about Z3Py at:
http://rise4fun.com/Z3Py/tutorial/guide
On Windows, you must build Z3 before using Z3Py.
To build Z3, you should executed the following command
On Windows, to build Z3, you should executed the following command
in the Z3 root directory at the Visual Studio Command Prompt
msbuild /p:configuration=external
@ -12,8 +8,8 @@ If you are using a 64-bit Python interpreter, you should use
msbuild /p:configuration=external /p:platform=x64
On Linux and macOS, you must install Z3Py, before trying example.py.
To install Z3Py on Linux and macOS, you should execute the following
On Linux and macOS, you must install python bindings, before trying example.py.
To install python on Linux and macOS, you should execute the following
command in the Z3 root directory
sudo make install-z3py

View file

@ -10,13 +10,14 @@ from distutils.util import get_platform
from distutils.errors import LibError
from distutils.command.build import build as _build
from distutils.command.sdist import sdist as _sdist
from distutils.command.clean import clean as _clean
from setuptools.command.develop import develop as _develop
from setuptools.command.bdist_egg import bdist_egg as _bdist_egg
build_env = dict(os.environ)
build_env['PYTHON'] = sys.executable
build_env['CXXFLAGS'] = "-std=c++11"
build_env['CXXFLAGS'] = build_env.get('CXXFLAGS', '') + " -std=c++11"
ROOT_DIR = os.path.abspath(os.path.dirname(__file__))
SRC_DIR_LOCAL = os.path.join(ROOT_DIR, 'core')
@ -37,13 +38,23 @@ else:
LIBRARY_FILE = "libz3.so"
EXECUTABLE_FILE = "z3"
def rmtree(tree):
if os.path.exists(tree):
shutil.rmtree(tree, ignore_errors=False)
def _clean_bins():
"""
Clean up the binary files and headers that are installed along with the bindings
"""
shutil.rmtree(LIBS_DIR, ignore_errors=True)
shutil.rmtree(BINS_DIR, ignore_errors=True)
shutil.rmtree(HEADERS_DIR, ignore_errors=True)
rmtree(LIBS_DIR)
rmtree(BINS_DIR)
rmtree(HEADERS_DIR)
def _clean_native_build():
"""
Clean the "build" directory in the z3 native root
"""
rmtree(BUILD_DIR)
def _z3_version():
post = os.getenv('Z3_VERSION_SUFFIX', '')
@ -146,10 +157,16 @@ class bdist_egg(_bdist_egg):
class sdist(_sdist):
def run(self):
self.execute(_clean_bins, (), msg="Cleaning binary files")
self.execute(_clean_bins, (), msg="Cleaning binary files and headers")
self.execute(_copy_sources, (), msg="Copying source files")
_sdist.run(self)
class clean(_clean):
def run(self):
self.execute(_clean_bins, (), msg="Cleaning binary files and headers")
self.execute(_clean_native_build, (), msg="Cleaning native build")
_clean.run(self)
# the build directory needs to exist
#try: os.makedirs(os.path.join(ROOT_DIR, 'build'))
#except OSError: pass
@ -178,7 +195,7 @@ setup(
name='z3-solver',
version=_z3_version(),
description='an efficient SMT solver library',
long_description='Z3 is a theorem prover from Microsoft Research with support for bitvectors, booleans, arrays, floating point numbers, strings, and other data types.\n\nFor documentation, please read http://z3prover.github.io/api/html/z3.html\n\nIn the event of technical difficulties related to configuration, compiliation, or installation, please submit issues to https://github.com/angr/angr-z3',
long_description='Z3 is a theorem prover from Microsoft Research with support for bitvectors, booleans, arrays, floating point numbers, strings, and other data types.\n\nFor documentation, please read http://z3prover.github.io/api/html/z3.html\n\nIn the event of technical difficulties related to configuration, compilation, or installation, please submit issues to https://github.com/angr/angr-z3',
author="The Z3 Theorem Prover Project",
maintainer="Audrey Dutcher",
maintainer_email="audrey@rhelmot.io",
@ -191,5 +208,5 @@ setup(
'z3': [os.path.join('lib', '*'), os.path.join('include', '*.h'), os.path.join('include', 'c++', '*.h')]
},
data_files=[('bin',[os.path.join('bin',EXECUTABLE_FILE)])],
cmdclass={'build': build, 'develop': develop, 'sdist': sdist, 'bdist_egg': bdist_egg},
cmdclass={'build': build, 'develop': develop, 'sdist': sdist, 'bdist_egg': bdist_egg, 'clean': clean},
)

View file

@ -482,6 +482,7 @@ def _to_ast_ref(a, ctx):
else:
return _to_expr_ref(a, ctx)
#########################################
#
# Sorts
@ -3836,7 +3837,7 @@ def Extract(high, low, a):
>>> Extract(6, 2, x).sort()
BitVec(5)
>>> simplify(Extract(StringVal("abcd"),2,1))
"c"
c
"""
if isinstance(high, str):
high = StringVal(high)
@ -4489,11 +4490,15 @@ def K(dom, v):
return ArrayRef(Z3_mk_const_array(ctx.ref(), dom.ast, v.as_ast()), ctx)
def Ext(a, b):
"""Return extensionality index for arrays.
"""Return extensionality index for one-dimensional arrays.
>> a, b = Consts('a b', SetSort(IntSort()))
>> Ext(a, b)
Ext(a, b)
"""
ctx = a.ctx
if __debug__:
_z3_assert(is_array(a) and is_array(b))
return _to_expr_ref(Z3_mk_array_ext(ctx.ref(), a.as_ast(), b.as_ast()));
_z3_assert(is_array(a) and is_array(b), "arguments must be arrays")
return _to_expr_ref(Z3_mk_array_ext(ctx.ref(), a.as_ast(), b.as_ast()), ctx)
def is_select(a):
"""Return `True` if `a` is a Z3 array select application.
@ -5339,7 +5344,7 @@ class Goal(Z3PPObject):
def __copy__(self):
return self.translate(self.ctx)
def __deepcopy__(self):
def __deepcopy__(self, memo={}):
return self.translate(self.ctx)
def simplify(self, *arguments, **keywords):
@ -5527,7 +5532,7 @@ class AstVector(Z3PPObject):
def __copy__(self):
return self.translate(self.ctx)
def __deepcopy__(self):
def __deepcopy__(self, memo={}):
return self.translate(self.ctx)
def __repr__(self):
@ -5871,7 +5876,7 @@ class FuncInterp(Z3PPObject):
def __copy__(self):
return self.translate(self.ctx)
def __deepcopy__(self):
def __deepcopy__(self, memo={}):
return self.translate(self.ctx)
def as_list(self):
@ -6167,7 +6172,7 @@ class ModelRef(Z3PPObject):
def __copy__(self):
return self.translate(self.ctx)
def __deepcopy__(self):
def __deepcopy__(self, memo={}):
return self.translate(self.ctx)
def Model(ctx = None):
@ -6664,17 +6669,11 @@ class Solver(Z3PPObject):
def from_file(self, filename):
"""Parse assertions from a file"""
try:
Z3_solver_from_file(self.ctx.ref(), self.solver, filename)
except Z3Exception as e:
_handle_parse_error(e, self.ctx)
Z3_solver_from_file(self.ctx.ref(), self.solver, filename)
def from_string(self, s):
"""Parse assertions from a string"""
try:
Z3_solver_from_string(self.ctx.ref(), self.solver, s)
except Z3Exception as e:
_handle_parse_error(e, self.ctx)
Z3_solver_from_string(self.ctx.ref(), self.solver, s)
def cube(self, vars = None):
"""Get set of cubes
@ -6732,6 +6731,25 @@ class Solver(Z3PPObject):
"""
return AstVector(Z3_solver_get_non_units(self.ctx.ref(), self.solver), self.ctx)
def trail_levels(self):
"""Return trail and decision levels of the solver state after a check() call.
"""
trail = self.trail()
levels = (ctypes.c_uint * len(trail))()
Z3_solver_get_levels(self.ctx.ref(), self.solver, trail.vector, len(trail), levels)
return trail, levels
def trail(self):
"""Return trail of the solver state after a check() call.
"""
return AstVector(Z3_solver_get_trail(self.ctx.ref(), self.solver), self.ctx)
def set_activity(self, lit, act):
"""Set activity of literal on solver object.
This influences the case split order of the variable.
"""
Z3_solver_set_activity(self.ctx.ref(), self.solver, lit.ast, act)
def statistics(self):
"""Return statistics for the last `check()`.
@ -6791,7 +6809,7 @@ class Solver(Z3PPObject):
def __copy__(self):
return self.translate(self.ctx)
def __deepcopy__(self):
def __deepcopy__(self, memo={}):
return self.translate(self.ctx)
def sexpr(self):
@ -6805,6 +6823,10 @@ class Solver(Z3PPObject):
"""
return Z3_solver_to_string(self.ctx.ref(), self.solver)
def dimacs(self):
"""Return a textual representation of the solver in DIMACS format."""
return Z3_solver_to_dimacs_string(self.ctx.ref(), self.solver)
def to_smt2(self):
"""return SMTLIB2 formatted benchmark for solver's assertions"""
es = self.assertions()
@ -7063,17 +7085,11 @@ class Fixedpoint(Z3PPObject):
def parse_string(self, s):
"""Parse rules and queries from a string"""
try:
return AstVector(Z3_fixedpoint_from_string(self.ctx.ref(), self.fixedpoint, s), self.ctx)
except Z3Exception as e:
_handle_parse_error(e, self.ctx)
return AstVector(Z3_fixedpoint_from_string(self.ctx.ref(), self.fixedpoint, s), self.ctx)
def parse_file(self, f):
"""Parse rules and queries from a file"""
try:
return AstVector(Z3_fixedpoint_from_file(self.ctx.ref(), self.fixedpoint, f), self.ctx)
except Z3Exception as e:
_handle_parse_error(e, self.ctx)
return AstVector(Z3_fixedpoint_from_file(self.ctx.ref(), self.fixedpoint, f), self.ctx)
def get_rules(self):
"""retrieve rules that have been added to fixedpoint context"""
@ -7330,6 +7346,35 @@ class Optimize(Z3PPObject):
self.add(fml)
return self
def assert_and_track(self, a, p):
"""Assert constraint `a` and track it in the unsat core using the Boolean constant `p`.
If `p` is a string, it will be automatically converted into a Boolean constant.
>>> x = Int('x')
>>> p3 = Bool('p3')
>>> s = Optimize()
>>> s.assert_and_track(x > 0, 'p1')
>>> s.assert_and_track(x != 1, 'p2')
>>> s.assert_and_track(x < 0, p3)
>>> print(s.check())
unsat
>>> c = s.unsat_core()
>>> len(c)
2
>>> Bool('p1') in c
True
>>> Bool('p2') in c
False
>>> p3 in c
True
"""
if isinstance(p, str):
p = Bool(p, self.ctx)
_z3_assert(isinstance(a, BoolRef), "Boolean expression expected")
_z3_assert(isinstance(p, BoolRef) and is_const(p), "Boolean expression expected")
Z3_optimize_assert_and_track(self.ctx.ref(), self.optimize, a.as_ast(), p.as_ast())
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
@ -7410,17 +7455,11 @@ class Optimize(Z3PPObject):
def from_file(self, filename):
"""Parse assertions and objectives from a file"""
try:
Z3_optimize_from_file(self.ctx.ref(), self.optimize, filename)
except Z3Exception as e:
_handle_parse_error(e, self.ctx)
Z3_optimize_from_file(self.ctx.ref(), self.optimize, filename)
def from_string(self, s):
"""Parse assertions and objectives from a string"""
try:
Z3_optimize_from_string(self.ctx.ref(), self.optimize, s)
except Z3Exception as e:
_handle_parse_error(e, self.ctx)
Z3_optimize_from_string(self.ctx.ref(), self.optimize, s)
def assertions(self):
"""Return an AST vector containing all added constraints."""
@ -9914,6 +9953,8 @@ class SeqRef(ExprRef):
def as_string(self):
"""Return a string representation of sequence expression."""
if self.is_string_value():
return Z3_get_string(self.ctx_ref(), self.as_ast())
return Z3_ast_to_string(self.ctx_ref(), self.as_ast())
@ -9993,8 +10034,6 @@ def Strings(names, ctx=None):
def Empty(s):
"""Create the empty sequence of the given sort
>>> e = Empty(StringSort())
>>> print(e)
""
>>> e2 = StringVal("")
>>> print(e.eq(e2))
True
@ -10080,7 +10119,7 @@ def Replace(s, src, dst):
"""Replace the first occurrence of 'src' by 'dst' in 's'
>>> r = Replace("aaa", "a", "b")
>>> simplify(r)
"baa"
baa
"""
ctx = _get_ctx2(dst, s)
if ctx is None and is_expr(src):

View file

@ -1515,19 +1515,19 @@ extern "C" {
although some parameters can be changed using #Z3_update_param_value.
All main interaction with Z3 happens in the context of a \c Z3_context.
In contrast to #Z3_mk_context_rc, the life time of Z3_ast objects
In contrast to #Z3_mk_context_rc, the life time of \c Z3_ast objects
are determined by the scope level of #Z3_solver_push and #Z3_solver_pop.
In other words, a Z3_ast object remains valid until there is a
call to Z3_solver_pop that takes the current scope below the level where
In other words, a \c Z3_ast object remains valid until there is a
call to #Z3_solver_pop that takes the current scope below the level where
the object was created.
Note that all other reference counted objects, including Z3_model,
Z3_solver, Z3_func_interp have to be managed by the caller.
Note that all other reference counted objects, including \c Z3_model,
\c Z3_solver, \c Z3_func_interp have to be managed by the caller.
Their reference counts are not handled by the context.
Further remarks:
- Z3_sort, Z3_func_decl, Z3_app, Z3_pattern are Z3_ast's.
- Z3 uses hash-consing, i.e., when the same Z3_ast is created twice,
- \c Z3_sort, \c Z3_func_decl, \c Z3_app, \c Z3_pattern are \c Z3_ast's.
- Z3 uses hash-consing, i.e., when the same \c Z3_ast is created twice,
Z3 will return the same pointer twice.
\sa Z3_del_context
@ -1540,20 +1540,20 @@ extern "C" {
\brief Create a context using the given configuration.
This function is similar to #Z3_mk_context. However,
in the context returned by this function, the user
is responsible for managing Z3_ast reference counters.
is responsible for managing \c Z3_ast reference counters.
Managing reference counters is a burden and error-prone,
but allows the user to use the memory more efficiently.
The user must invoke #Z3_inc_ref for any Z3_ast returned
by Z3, and #Z3_dec_ref whenever the Z3_ast is not needed
The user must invoke #Z3_inc_ref for any \c Z3_ast returned
by Z3, and #Z3_dec_ref whenever the \c Z3_ast is not needed
anymore. This idiom is similar to the one used in
BDD (binary decision diagrams) packages such as CUDD.
Remarks:
- Z3_sort, Z3_func_decl, Z3_app, Z3_pattern are Z3_ast's.
- \c Z3_sort, \c Z3_func_decl, \c Z3_app, \c Z3_pattern are \c Z3_ast's.
- After a context is created, the configuration cannot be changed.
- All main interaction with Z3 happens in the context of a \c Z3_context.
- Z3 uses hash-consing, i.e., when the same Z3_ast is created twice,
- Z3 uses hash-consing, i.e., when the same \c Z3_ast is created twice,
Z3 will return the same pointer twice.
def_API('Z3_mk_context_rc', CONTEXT, (_in(CONFIG),))
@ -1615,7 +1615,7 @@ extern "C" {
Starting at Z3 4.0, parameter sets are used to configure many components such as:
simplifiers, tactics, solvers, etc.
\remark Reference counting must be used to manage parameter sets, even when the Z3_context was
\remark Reference counting must be used to manage parameter sets, even when the \c Z3_context was
created using #Z3_mk_context instead of #Z3_mk_context_rc.
def_API('Z3_mk_params', PARAMS, (_in(CONTEXT),))
@ -4094,7 +4094,7 @@ extern "C" {
The remaining fields are left unchanged. It is the record
equivalent of an array store (see \sa Z3_mk_store).
If the datatype has more than one constructor, then the update function
behaves as identity if there is a miss-match between the accessor and
behaves as identity if there is a mismatch between the accessor and
constructor. For example ((_ update-field car) nil 1) is nil,
while ((_ update-field car) (cons 2 nil) 1) is (cons 1 nil).
@ -4416,7 +4416,7 @@ extern "C" {
bool Z3_API Z3_is_well_sorted(Z3_context c, Z3_ast t);
/**
\brief Return Z3_L_TRUE if \c a is true, Z3_L_FALSE if it is false, and Z3_L_UNDEF otherwise.
\brief Return \c Z3_L_TRUE if \c a is true, \c Z3_L_FALSE if it is false, and \c Z3_L_UNDEF otherwise.
def_API('Z3_get_bool_value', INT, (_in(CONTEXT), _in(AST)))
*/
@ -4998,7 +4998,7 @@ extern "C" {
Z3_ast_vector Z3_API Z3_model_get_sort_universe(Z3_context c, Z3_model m, Z3_sort s);
/**
\brief translate model from context c to context \c dst.
\brief translate model from context \c c to context \c dst.
def_API('Z3_model_translate', MODEL, (_in(CONTEXT), _in(MODEL), _in(CONTEXT)))
*/
@ -6213,6 +6213,13 @@ extern "C" {
*/
Z3_ast_vector Z3_API Z3_solver_get_units(Z3_context c, Z3_solver s);
/**
\brief Return the trail modulo model conversion, in order of decision level
The decision level can be retrieved using \c Z3_solver_get_level based on the trail.
def_API('Z3_solver_get_trail', AST_VECTOR, (_in(CONTEXT), _in(SOLVER)))
*/
Z3_ast_vector Z3_API Z3_solver_get_trail(Z3_context c, Z3_solver s);
/**
\brief Return the set of non units in the solver state.
@ -6221,13 +6228,28 @@ extern "C" {
*/
Z3_ast_vector Z3_API Z3_solver_get_non_units(Z3_context c, Z3_solver s);
/**
\brief retrieve the decision depth of Boolean literals (variables or their negations).
Assumes a check-sat call and no other calls (to extract models) have been invoked.
def_API('Z3_solver_get_levels', VOID, (_in(CONTEXT), _in(SOLVER), _in(AST_VECTOR), _in(UINT), _in_array(3, UINT)))
*/
void Z3_API Z3_solver_get_levels(Z3_context c, Z3_solver s, Z3_ast_vector literals, unsigned sz, unsigned levels[]);
/**
\brief set activity score associated with literal.
def_API('Z3_solver_set_activity', VOID, (_in(CONTEXT), _in(SOLVER), _in(AST), _in(DOUBLE)))
*/
void Z3_API Z3_solver_set_activity(Z3_context c, Z3_solver s, Z3_ast l, double activity);
/**
\brief Check whether the assertions in a given solver are consistent or not.
The function #Z3_solver_get_model retrieves a model if the
assertions is satisfiable (i.e., the result is \c
Z3_L_TRUE) and model construction is enabled.
Note that if the call returns Z3_L_UNDEF, Z3 does not
Note that if the call returns \c Z3_L_UNDEF, Z3 does not
ensure that calls to #Z3_solver_get_model succeed and any models
produced in this case are not guaranteed to satisfy the assertions.
@ -6269,7 +6291,7 @@ extern "C" {
the current context implies that they are equal.
A side-effect of the function is a satisfiability check on the assertions on the solver that is passed in.
The function return Z3_L_FALSE if the current assertions are not satisfiable.
The function return \c Z3_L_FALSE if the current assertions are not satisfiable.
def_API('Z3_get_implied_equalities', INT, (_in(CONTEXT), _in(SOLVER), _in(UINT), _in_array(2, AST), _out_array(2, UINT)))
*/
@ -6342,7 +6364,7 @@ extern "C" {
Z3_ast_vector Z3_API Z3_solver_get_unsat_core(Z3_context c, Z3_solver s);
/**
\brief Return a brief justification for an "unknown" result (i.e., Z3_L_UNDEF) for
\brief Return a brief justification for an "unknown" result (i.e., \c Z3_L_UNDEF) for
the commands #Z3_solver_check and #Z3_solver_check_assumptions
def_API('Z3_solver_get_reason_unknown', STRING, (_in(CONTEXT), _in(SOLVER)))
@ -6368,6 +6390,14 @@ extern "C" {
*/
Z3_string Z3_API Z3_solver_to_string(Z3_context c, Z3_solver s);
/**
\brief Convert a solver into a DIMACS formatted string.
\sa Z3_goal_to_diamcs_string for requirements.
def_API('Z3_solver_to_dimacs_string', STRING, (_in(CONTEXT), _in(SOLVER)))
*/
Z3_string Z3_API Z3_solver_to_dimacs_string(Z3_context c, Z3_solver s);
/*@}*/
/** @name Statistics */

View file

@ -106,9 +106,9 @@ extern "C" {
\endcode
query returns
- Z3_L_FALSE if the query is unsatisfiable.
- Z3_L_TRUE if the query is satisfiable. Obtain the answer by calling #Z3_fixedpoint_get_answer.
- Z3_L_UNDEF if the query was interrupted, timed out or otherwise failed.
- \c Z3_L_FALSE if the query is unsatisfiable.
- \c Z3_L_TRUE if the query is satisfiable. Obtain the answer by calling #Z3_fixedpoint_get_answer.
- \c Z3_L_UNDEF if the query was interrupted, timed out or otherwise failed.
def_API('Z3_fixedpoint_query', INT, (_in(CONTEXT), _in(FIXEDPOINT), _in(AST)))
*/
@ -120,9 +120,9 @@ extern "C" {
The queries are encoded as relations (function declarations).
query returns
- Z3_L_FALSE if the query is unsatisfiable.
- Z3_L_TRUE if the query is satisfiable. Obtain the answer by calling #Z3_fixedpoint_get_answer.
- Z3_L_UNDEF if the query was interrupted, timed out or otherwise failed.
- \c Z3_L_FALSE if the query is unsatisfiable.
- \c Z3_L_TRUE if the query is satisfiable. Obtain the answer by calling #Z3_fixedpoint_get_answer.
- \c Z3_L_UNDEF if the query was interrupted, timed out or otherwise failed.
def_API('Z3_fixedpoint_query_relations', INT, (_in(CONTEXT), _in(FIXEDPOINT), _in(UINT), _in_array(2, FUNC_DECL)))
*/
@ -138,8 +138,8 @@ extern "C" {
Each conjunct encodes values of the bound variables of the query that are satisfied.
In PDR mode, the returned answer is a single conjunction.
When used in Datalog mode the previous call to #Z3_fixedpoint_query must have returned Z3_L_TRUE.
When used with the PDR engine, the previous call must have been either Z3_L_TRUE or Z3_L_FALSE.
When used in Datalog mode the previous call to #Z3_fixedpoint_query must have returned \c Z3_L_TRUE.
When used with the PDR engine, the previous call must have been either \c Z3_L_TRUE or \c Z3_L_FALSE.
def_API('Z3_fixedpoint_get_answer', AST, (_in(CONTEXT), _in(FIXEDPOINT)))
*/
@ -148,7 +148,7 @@ extern "C" {
/**
\brief Retrieve a string that describes the last status returned by #Z3_fixedpoint_query.
Use this method when #Z3_fixedpoint_query returns Z3_L_UNDEF.
Use this method when #Z3_fixedpoint_query returns \c Z3_L_UNDEF.
def_API('Z3_fixedpoint_get_reason_unknown', STRING, (_in(CONTEXT), _in(FIXEDPOINT) ))
*/
@ -395,7 +395,7 @@ extern "C" {
Z3_fixedpoint_predecessor_eh predecessor_eh,
Z3_fixedpoint_unfold_eh unfold_eh);
void Z3_fixedpoint_add_constraint (Z3_context c, Z3_fixedpoint d, Z3_ast e, unsigned lvl);
void Z3_API Z3_fixedpoint_add_constraint (Z3_context c, Z3_fixedpoint d, Z3_ast e, unsigned lvl);
/*@}*/
/*@}*/

View file

@ -134,7 +134,7 @@ extern "C" {
\param ebits number of exponent bits
\param sbits number of significand bits
\remark ebits must be larger than 1 and sbits must be larger than 2.
\remark \c ebits must be larger than 1 and \c sbits must be larger than 2.
def_API('Z3_mk_fpa_sort', SORT, (_in(CONTEXT), _in(UINT), _in(UINT)))
*/
@ -213,7 +213,7 @@ extern "C" {
Z3_sort Z3_API Z3_mk_fpa_sort_128(Z3_context c);
/**
\brief Create a floating-point NaN of sort s.
\brief Create a floating-point NaN of sort \c s.
\param c logical context
\param s target sort
@ -223,7 +223,7 @@ extern "C" {
Z3_ast Z3_API Z3_mk_fpa_nan(Z3_context c, Z3_sort s);
/**
\brief Create a floating-point infinity of sort s.
\brief Create a floating-point infinity of sort \c s.
\param c logical context
\param s target sort
@ -236,7 +236,7 @@ extern "C" {
Z3_ast Z3_API Z3_mk_fpa_inf(Z3_context c, Z3_sort s, bool negative);
/**
\brief Create a floating-point zero of sort s.
\brief Create a floating-point zero of sort \c s.
\param c logical context
\param s target sort
@ -252,7 +252,7 @@ extern "C" {
\brief Create an expression of FloatingPoint sort from three bit-vector expressions.
This is the operator named `fp' in the SMT FP theory definition.
Note that \c sign is required to be a bit-vector of size 1. Significand and exponent
Note that \c sgn is required to be a bit-vector of size 1. Significand and exponent
are required to be longer than 1 and 2 respectively. The FloatingPoint sort
of the resulting expression is automatically determined from the bit-vector sizes
of the arguments. The exponent is assumed to be in IEEE-754 biased representation.
@ -276,7 +276,7 @@ extern "C" {
\param v value
\param ty sort
ty must be a FloatingPoint sort
\c ty must be a FloatingPoint sort
\sa Z3_mk_numeral
@ -294,7 +294,7 @@ extern "C" {
\param v value
\param ty sort
ty must be a FloatingPoint sort
\c ty must be a FloatingPoint sort
\sa Z3_mk_numeral
@ -309,7 +309,7 @@ extern "C" {
\param v value
\param ty result sort
ty must be a FloatingPoint sort
\c ty must be a FloatingPoint sort
\sa Z3_mk_numeral
@ -326,7 +326,7 @@ extern "C" {
\param exp exponent
\param ty result sort
ty must be a FloatingPoint sort
\c ty must be a FloatingPoint sort
\sa Z3_mk_numeral
@ -343,7 +343,7 @@ extern "C" {
\param exp exponent
\param ty result sort
ty must be a FloatingPoint sort
\c ty must be a FloatingPoint sort
\sa Z3_mk_numeral
@ -379,7 +379,7 @@ extern "C" {
\param t1 term of FloatingPoint sort
\param t2 term of FloatingPoint sort
rm must be of RoundingMode sort, t1 and t2 must have the same FloatingPoint sort.
\c rm must be of RoundingMode sort, \c t1 and \c t2 must have the same FloatingPoint sort.
def_API('Z3_mk_fpa_add', AST, (_in(CONTEXT),_in(AST),_in(AST),_in(AST)))
*/
@ -393,7 +393,7 @@ extern "C" {
\param t1 term of FloatingPoint sort
\param t2 term of FloatingPoint sort
rm must be of RoundingMode sort, t1 and t2 must have the same FloatingPoint sort.
\c rm must be of RoundingMode sort, \c t1 and \c t2 must have the same FloatingPoint sort.
def_API('Z3_mk_fpa_sub', AST, (_in(CONTEXT),_in(AST),_in(AST),_in(AST)))
*/
@ -407,7 +407,7 @@ extern "C" {
\param t1 term of FloatingPoint sort
\param t2 term of FloatingPoint sort
rm must be of RoundingMode sort, t1 and t2 must have the same FloatingPoint sort.
\c rm must be of RoundingMode sort, \c t1 and \c t2 must have the same FloatingPoint sort.
def_API('Z3_mk_fpa_mul', AST, (_in(CONTEXT),_in(AST),_in(AST),_in(AST)))
*/
@ -421,7 +421,7 @@ extern "C" {
\param t1 term of FloatingPoint sort.
\param t2 term of FloatingPoint sort
The nodes rm must be of RoundingMode sort t1 and t2 must have the same FloatingPoint sort.
The nodes \c rm must be of RoundingMode sort, \c t1 and \c t2 must have the same FloatingPoint sort.
def_API('Z3_mk_fpa_div', AST, (_in(CONTEXT),_in(AST),_in(AST),_in(AST)))
*/
@ -436,9 +436,9 @@ extern "C" {
\param t2 term of FloatingPoint sort
\param t3 term of FloatingPoint sort
The result is round((t1 * t2) + t3)
The result is \ccode{round((t1 * t2) + t3)}.
rm must be of RoundingMode sort, t1, t2, and t3 must have the same FloatingPoint sort.
\c rm must be of RoundingMode sort, \c t1, \c t2, and \c t3 must have the same FloatingPoint sort.
def_API('Z3_mk_fpa_fma', AST, (_in(CONTEXT),_in(AST),_in(AST),_in(AST),_in(AST)))
*/
@ -451,7 +451,7 @@ extern "C" {
\param rm term of RoundingMode sort
\param t term of FloatingPoint sort
rm must be of RoundingMode sort, t must have FloatingPoint sort.
\c rm must be of RoundingMode sort, \c t must have FloatingPoint sort.
def_API('Z3_mk_fpa_sqrt', AST, (_in(CONTEXT),_in(AST),_in(AST)))
*/
@ -464,7 +464,7 @@ extern "C" {
\param t1 term of FloatingPoint sort
\param t2 term of FloatingPoint sort
t1 and t2 must have the same FloatingPoint sort.
\c t1 and \c t2 must have the same FloatingPoint sort.
def_API('Z3_mk_fpa_rem', AST, (_in(CONTEXT),_in(AST),_in(AST)))
*/
@ -478,7 +478,7 @@ extern "C" {
\param rm term of RoundingMode sort
\param t term of FloatingPoint sort
t must be of FloatingPoint sort.
\c t must be of FloatingPoint sort.
def_API('Z3_mk_fpa_round_to_integral', AST, (_in(CONTEXT),_in(AST),_in(AST)))
*/
@ -491,7 +491,7 @@ extern "C" {
\param t1 term of FloatingPoint sort
\param t2 term of FloatingPoint sort
t1, t2 must have the same FloatingPoint sort.
\c t1, \c t2 must have the same FloatingPoint sort.
def_API('Z3_mk_fpa_min', AST, (_in(CONTEXT),_in(AST),_in(AST)))
*/
@ -504,7 +504,7 @@ extern "C" {
\param t1 term of FloatingPoint sort
\param t2 term of FloatingPoint sort
t1, t2 must have the same FloatingPoint sort.
\c t1, \c t2 must have the same FloatingPoint sort.
def_API('Z3_mk_fpa_max', AST, (_in(CONTEXT),_in(AST),_in(AST)))
*/
@ -517,7 +517,7 @@ extern "C" {
\param t1 term of FloatingPoint sort
\param t2 term of FloatingPoint sort
t1 and t2 must have the same FloatingPoint sort.
\c t1 and \c t2 must have the same FloatingPoint sort.
def_API('Z3_mk_fpa_leq', AST, (_in(CONTEXT),_in(AST),_in(AST)))
*/
@ -530,7 +530,7 @@ extern "C" {
\param t1 term of FloatingPoint sort
\param t2 term of FloatingPoint sort
t1 and t2 must have the same FloatingPoint sort.
\c t1 and \c t2 must have the same FloatingPoint sort.
def_API('Z3_mk_fpa_lt', AST, (_in(CONTEXT),_in(AST),_in(AST)))
*/
@ -543,7 +543,7 @@ extern "C" {
\param t1 term of FloatingPoint sort
\param t2 term of FloatingPoint sort
t1 and t2 must have the same FloatingPoint sort.
\c t1 and \c t2 must have the same FloatingPoint sort.
def_API('Z3_mk_fpa_geq', AST, (_in(CONTEXT),_in(AST),_in(AST)))
*/
@ -556,7 +556,7 @@ extern "C" {
\param t1 term of FloatingPoint sort
\param t2 term of FloatingPoint sort
t1 and t2 must have the same FloatingPoint sort.
\c t1 and \c t2 must have the same FloatingPoint sort.
def_API('Z3_mk_fpa_gt', AST, (_in(CONTEXT),_in(AST),_in(AST)))
*/
@ -569,93 +569,93 @@ extern "C" {
\param t1 term of FloatingPoint sort
\param t2 term of FloatingPoint sort
Note that this is IEEE 754 equality (as opposed to SMT-LIB =).
Note that this is IEEE 754 equality (as opposed to SMT-LIB \ccode{=}).
t1 and t2 must have the same FloatingPoint sort.
\c t1 and \c t2 must have the same FloatingPoint sort.
def_API('Z3_mk_fpa_eq', AST, (_in(CONTEXT),_in(AST),_in(AST)))
*/
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.
\brief Predicate indicating whether \c t is a normal floating-point number.
\param c logical context
\param t term of FloatingPoint sort
t must have FloatingPoint sort.
\c t must have FloatingPoint sort.
def_API('Z3_mk_fpa_is_normal', AST, (_in(CONTEXT),_in(AST)))
*/
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.
\brief Predicate indicating whether \c t is a subnormal floating-point number.
\param c logical context
\param t term of FloatingPoint sort
t must have FloatingPoint sort.
\c t must have FloatingPoint sort.
def_API('Z3_mk_fpa_is_subnormal', AST, (_in(CONTEXT),_in(AST)))
*/
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.
\brief Predicate indicating whether \c t is a floating-point number with zero value, i.e., +zero or -zero.
\param c logical context
\param t term of FloatingPoint sort
t must have FloatingPoint sort.
\c t must have FloatingPoint sort.
def_API('Z3_mk_fpa_is_zero', AST, (_in(CONTEXT),_in(AST)))
*/
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.
\brief Predicate indicating whether \c t is a floating-point number representing +oo or -oo.
\param c logical context
\param t term of FloatingPoint sort
t must have FloatingPoint sort.
\c t must have FloatingPoint sort.
def_API('Z3_mk_fpa_is_infinite', AST, (_in(CONTEXT),_in(AST)))
*/
Z3_ast Z3_API Z3_mk_fpa_is_infinite(Z3_context c, Z3_ast t);
/**
\brief Predicate indicating whether t is a NaN.
\brief Predicate indicating whether \c t is a NaN.
\param c logical context
\param t term of FloatingPoint sort
t must have FloatingPoint sort.
\c t must have FloatingPoint sort.
def_API('Z3_mk_fpa_is_nan', AST, (_in(CONTEXT),_in(AST)))
*/
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.
\brief Predicate indicating whether \c t is a negative floating-point number.
\param c logical context
\param t term of FloatingPoint sort
t must have FloatingPoint sort.
\c t must have FloatingPoint sort.
def_API('Z3_mk_fpa_is_negative', AST, (_in(CONTEXT),_in(AST)))
*/
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.
\brief Predicate indicating whether \c t is a positive floating-point number.
\param c logical context
\param t term of FloatingPoint sort
t must have FloatingPoint sort.
\c t must have FloatingPoint sort.
def_API('Z3_mk_fpa_is_positive', AST, (_in(CONTEXT),_in(AST)))
*/
@ -664,15 +664,15 @@ extern "C" {
/**
\brief Conversion of a single IEEE 754-2008 bit-vector into a floating-point number.
Produces a term that represents the conversion of a bit-vector term bv to a
floating-point term of sort s.
Produces a term that represents the conversion of a bit-vector term \c bv to a
floating-point term of sort \c s.
\param c logical context
\param bv a bit-vector term
\param s floating-point sort
s must be a FloatingPoint sort, t must be of bit-vector sort, and the bit-vector
size of bv must be equal to ebits+sbits of s. The format of the bit-vector is
\c s must be a FloatingPoint sort, \c t must be of bit-vector sort, and the bit-vector
size of \c bv must be equal to \ccode{ebits+sbits} of \c s. The format of the bit-vector is
as defined by the IEEE 754-2008 interchange format.
def_API('Z3_mk_fpa_to_fp_bv', AST, (_in(CONTEXT),_in(AST),_in(SORT)))
@ -682,16 +682,16 @@ extern "C" {
/**
\brief Conversion of a FloatingPoint term into another term of different FloatingPoint sort.
Produces a term that represents the conversion of a floating-point term t to a
floating-point term of sort s. If necessary, the result will be rounded according
to rounding mode rm.
Produces a term that represents the conversion of a floating-point term \c t to a
floating-point term of sort \c s. If necessary, the result will be rounded according
to rounding mode \c rm.
\param c logical context
\param rm term of RoundingMode sort
\param t term of FloatingPoint sort
\param s floating-point sort
s must be a FloatingPoint sort, rm must be of RoundingMode sort, t must be of floating-point sort.
\c s must be a FloatingPoint sort, \c rm must be of RoundingMode sort, \c t must be of floating-point sort.
def_API('Z3_mk_fpa_to_fp_float', AST, (_in(CONTEXT),_in(AST),_in(AST),_in(SORT)))
*/
@ -700,16 +700,16 @@ extern "C" {
/**
\brief Conversion of a term of real sort into a term of FloatingPoint sort.
Produces a term that represents the conversion of term t of real sort into a
floating-point term of sort s. If necessary, the result will be rounded according
to rounding mode rm.
Produces a term that represents the conversion of term \c t of real sort into a
floating-point term of sort \c s. If necessary, the result will be rounded according
to rounding mode \c rm.
\param c logical context
\param rm term of RoundingMode sort
\param t term of Real sort
\param s floating-point sort
s must be a FloatingPoint sort, rm must be of RoundingMode sort, t must be of real sort.
\c s must be a FloatingPoint sort, \c rm must be of RoundingMode sort, \c t must be of real sort.
def_API('Z3_mk_fpa_to_fp_real', AST, (_in(CONTEXT),_in(AST),_in(AST),_in(SORT)))
*/
@ -718,17 +718,17 @@ extern "C" {
/**
\brief Conversion of a 2's complement signed bit-vector term into a term of FloatingPoint sort.
Produces a term that represents the conversion of the bit-vector term t into a
floating-point term of sort s. The bit-vector t is taken to be in signed
Produces a term that represents the conversion of the bit-vector term \c t into a
floating-point term of sort \c s. The bit-vector \c t is taken to be in signed
2's complement format. If necessary, the result will be rounded according
to rounding mode rm.
to rounding mode \c rm.
\param c logical context
\param rm term of RoundingMode sort
\param t term of bit-vector sort
\param s floating-point sort
s must be a FloatingPoint sort, rm must be of RoundingMode sort, t must be of bit-vector sort.
\c s must be a FloatingPoint sort, \c rm must be of RoundingMode sort, \c t must be of bit-vector sort.
def_API('Z3_mk_fpa_to_fp_signed', AST, (_in(CONTEXT),_in(AST),_in(AST),_in(SORT)))
*/
@ -737,17 +737,17 @@ extern "C" {
/**
\brief Conversion of a 2's complement unsigned bit-vector term into a term of FloatingPoint sort.
Produces a term that represents the conversion of the bit-vector term t into a
floating-point term of sort s. The bit-vector t is taken to be in unsigned
Produces a term that represents the conversion of the bit-vector term \c t into a
floating-point term of sort \c s. The bit-vector \c t is taken to be in unsigned
2's complement format. If necessary, the result will be rounded according
to rounding mode rm.
to rounding mode \c rm.
\param c logical context
\param rm term of RoundingMode sort
\param t term of bit-vector sort
\param s floating-point sort
s must be a FloatingPoint sort, rm must be of RoundingMode sort, t must be of bit-vector sort.
\c s must be a FloatingPoint sort, \c rm must be of RoundingMode sort, \c t must be of bit-vector sort.
def_API('Z3_mk_fpa_to_fp_unsigned', AST, (_in(CONTEXT),_in(AST),_in(AST),_in(SORT)))
*/
@ -756,9 +756,9 @@ extern "C" {
/**
\brief Conversion of a floating-point term into an unsigned bit-vector.
Produces a term that represents the conversion of the floating-point term t into a
bit-vector term of size sz in unsigned 2's complement format. If necessary, the result
will be rounded according to rounding mode rm.
Produces a term that represents the conversion of the floating-point term \c t into a
bit-vector term of size \c sz in unsigned 2's complement format. If necessary, the result
will be rounded according to rounding mode \c rm.
\param c logical context
\param rm term of RoundingMode sort
@ -772,9 +772,9 @@ extern "C" {
/**
\brief Conversion of a floating-point term into a signed bit-vector.
Produces a term that represents the conversion of the floating-point term t into a
bit-vector term of size sz in signed 2's complement format. If necessary, the result
will be rounded according to rounding mode rm.
Produces a term that represents the conversion of the floating-point term \c t into a
bit-vector term of size \c sz in signed 2's complement format. If necessary, the result
will be rounded according to rounding mode \c rm.
\param c logical context
\param rm term of RoundingMode sort
@ -788,7 +788,7 @@ extern "C" {
/**
\brief Conversion of a floating-point term into a real-numbered term.
Produces a term that represents the conversion of the floating-point term t into a
Produces a term that represents the conversion of the floating-point term \c t into a
real number. Note that this type of conversion will often result in non-linear
constraints over real terms.
@ -936,7 +936,7 @@ extern "C" {
\param c logical context
\param t a floating-point numeral
Remarks: The significand s is always 0.0 <= s < 2.0; the resulting string is long
Remarks: The significand \c s is always \ccode{0.0 <= s < 2.0}; the resulting string is long
enough to represent the real significand precisely.
def_API('Z3_fpa_get_numeral_significand_string', STRING, (_in(CONTEXT), _in(AST)))
@ -951,8 +951,8 @@ extern "C" {
\param n pointer to output uint64
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. NaN is an invalid argument.
hidden bit or normalization. Sets the \c Z3_INVALID_ARG error code if the
significand does not fit into a \c uint64. NaN is an invalid argument.
def_API('Z3_fpa_get_numeral_significand_uint64', BOOL, (_in(CONTEXT), _in(AST), _out(UINT64)))
*/
@ -1007,7 +1007,7 @@ extern "C" {
\param c logical context
\param t term of FloatingPoint sort
t must have FloatingPoint sort. The size of the resulting bit-vector is automatically
\c t must have FloatingPoint sort. The size of the resulting bit-vector is automatically
determined.
Note that IEEE 754-2008 allows multiple different representations of NaN. This conversion
@ -1021,9 +1021,9 @@ extern "C" {
/**
\brief Conversion of a real-sorted significand and an integer-sorted exponent into a term of FloatingPoint sort.
Produces a term that represents the conversion of sig * 2^exp into a
floating-point term of sort s. If necessary, the result will be rounded
according to rounding mode rm.
Produces a term that represents the conversion of \ccode{sig * 2^exp} into a
floating-point term of sort \c s. If necessary, the result will be rounded
according to rounding mode \c rm.
\param c logical context
\param rm term of RoundingMode sort
@ -1031,7 +1031,7 @@ extern "C" {
\param sig significand term of Real sort
\param s FloatingPoint sort
s must be a FloatingPoint sort, rm must be of RoundingMode sort, exp must be of int sort, sig must be of real sort.
\c s must be a FloatingPoint sort, \c rm must be of RoundingMode sort, \c exp must be of int sort, \c sig must be of real sort.
def_API('Z3_mk_fpa_to_fp_int_real', AST, (_in(CONTEXT),_in(AST),_in(AST),_in(AST),_in(SORT)))
*/

View file

@ -19,7 +19,3 @@ Copyright (c) 2015 Microsoft Corporation
#ifndef DEFINE_TYPE
#define DEFINE_TYPE(T) typedef struct _ ## T *T
#endif
#ifndef DEFINE_VOID
#define DEFINE_VOID(T) typedef void* T
#endif

View file

@ -56,11 +56,23 @@ extern "C" {
\brief Assert hard constraint to the optimization context.
\sa Z3_optimize_assert_soft
\sa Z3_optimize_assert_and_track
def_API('Z3_optimize_assert', VOID, (_in(CONTEXT), _in(OPTIMIZE), _in(AST)))
*/
void Z3_API Z3_optimize_assert(Z3_context c, Z3_optimize o, Z3_ast a);
/**
\brief Assert tracked hard constraint to the optimization context.
\sa Z3_optimize_assert
\sa Z3_optimize_assert_soft
def_API('Z3_optimize_assert_and_track', VOID, (_in(CONTEXT), _in(OPTIMIZE), _in(AST), _in(AST)))
*/
void Z3_API Z3_optimize_assert_and_track(Z3_context c, Z3_optimize o, Z3_ast a, Z3_ast t);
/**
\brief Assert soft constraint to the optimization context.
\param c - context
@ -142,7 +154,7 @@ extern "C" {
/**
\brief Retrieve a string that describes the last status returned by #Z3_optimize_check.
Use this method when #Z3_optimize_check returns Z3_L_UNDEF.
Use this method when #Z3_optimize_check returns \c Z3_L_UNDEF.
def_API('Z3_optimize_get_reason_unknown', STRING, (_in(CONTEXT), _in(OPTIMIZE) ))
*/
@ -228,8 +240,8 @@ extern "C" {
/**
\brief Retrieve lower bound value or approximation for the i'th optimization objective.
The returned vector is of length 3. It always contains numerals.
The three numerals are coefficients a, b, c and encode the result of \c Z3_optimize_get_lower
a * infinity + b + c * epsilon.
The three numerals are coefficients \c a, \c b, \c c and encode the result of
#Z3_optimize_get_lower \ccode{a * infinity + b + c * epsilon}.
\param c - context
\param o - optimization context
@ -330,7 +342,7 @@ extern "C" {
/**
\brief Return objectives on the optimization context.
If the objective function is a max-sat objective it is returned
as a Pseudo-Boolean (minimization) sum of the form (+ (if f1 w1 0) (if f2 w2 0) ...)
as a Pseudo-Boolean (minimization) sum of the form \ccode{(+ (if f1 w1 0) (if f2 w2 0) ...)}
If the objective function is entered as a maximization objective, then return
the corresponding minimization objective. In this way the resulting objective
function is always returned as a minimization objective.

View file

@ -36,9 +36,8 @@ extern "C" {
\pre \c p, \c q and \c x are Z3 expressions where \c p and \c q are arithmetic terms.
Note that, any subterm that cannot be viewed as a polynomial is assumed to be a variable.
Example: f(a) is a considered to be a variable in the polynomial
f(a)*f(a) + 2*f(a) + 1
Example: \ccode{f(a)} is a considered to be a variable in the polynomial \ccode{
f(a)*f(a) + 2*f(a) + 1}
def_API('Z3_polynomial_subresultants', AST_VECTOR, (_in(CONTEXT), _in(AST), _in(AST), _in(AST)))
*/

View file

@ -74,7 +74,7 @@ extern "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>.
\brief Store in roots the roots of the polynomial \ccode{a[n-1]*x^{n-1} + ... + a[0]}.
The output vector \c roots must have size \c n.
It returns the number of roots of the polynomial.
@ -85,91 +85,91 @@ extern "C" {
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.
\brief Return the value \ccode{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(Z3_context c, Z3_rcf_num a, Z3_rcf_num b);
/**
\brief Return the value a - b.
\brief Return the value \ccode{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(Z3_context c, Z3_rcf_num a, Z3_rcf_num b);
/**
\brief Return the value a * b.
\brief Return the value \ccode{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(Z3_context c, Z3_rcf_num a, Z3_rcf_num b);
/**
\brief Return the value a / b.
\brief Return the value \ccode{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(Z3_context c, Z3_rcf_num a, Z3_rcf_num b);
/**
\brief Return the value -a
\brief Return the value \ccode{-a}.
def_API('Z3_rcf_neg', RCF_NUM, (_in(CONTEXT), _in(RCF_NUM)))
*/
Z3_rcf_num Z3_API Z3_rcf_neg(Z3_context c, Z3_rcf_num a);
/**
\brief Return the value 1/a
\brief Return the value \ccode{1/a}.
def_API('Z3_rcf_inv', RCF_NUM, (_in(CONTEXT), _in(RCF_NUM)))
*/
Z3_rcf_num Z3_API Z3_rcf_inv(Z3_context c, Z3_rcf_num a);
/**
\brief Return the value a^k
\brief Return the value \ccode{a^k}.
def_API('Z3_rcf_power', RCF_NUM, (_in(CONTEXT), _in(RCF_NUM), _in(UINT)))
*/
Z3_rcf_num Z3_API Z3_rcf_power(Z3_context c, Z3_rcf_num a, unsigned k);
/**
\brief Return \c true if a < b
\brief Return \c true if \ccode{a < b}.
def_API('Z3_rcf_lt', BOOL, (_in(CONTEXT), _in(RCF_NUM), _in(RCF_NUM)))
*/
bool Z3_API Z3_rcf_lt(Z3_context c, Z3_rcf_num a, Z3_rcf_num b);
/**
\brief Return \c true if a > b
\brief Return \c true if \ccode{a > b}.
def_API('Z3_rcf_gt', BOOL, (_in(CONTEXT), _in(RCF_NUM), _in(RCF_NUM)))
*/
bool Z3_API Z3_rcf_gt(Z3_context c, Z3_rcf_num a, Z3_rcf_num b);
/**
\brief Return \c true if a <= b
\brief Return \c true if \ccode{a <= b}.
def_API('Z3_rcf_le', BOOL, (_in(CONTEXT), _in(RCF_NUM), _in(RCF_NUM)))
*/
bool Z3_API Z3_rcf_le(Z3_context c, Z3_rcf_num a, Z3_rcf_num b);
/**
\brief Return \c true if a >= b
\brief Return \c true if \ccode{a >= b}.
def_API('Z3_rcf_ge', BOOL, (_in(CONTEXT), _in(RCF_NUM), _in(RCF_NUM)))
*/
bool Z3_API Z3_rcf_ge(Z3_context c, Z3_rcf_num a, Z3_rcf_num b);
/**
\brief Return \c true if a == b
\brief Return \c true if \ccode{a == b}.
def_API('Z3_rcf_eq', BOOL, (_in(CONTEXT), _in(RCF_NUM), _in(RCF_NUM)))
*/
bool Z3_API Z3_rcf_eq(Z3_context c, Z3_rcf_num a, Z3_rcf_num b);
/**
\brief Return \c true if a != b
\brief Return \c true if \ccode{a != b}.
def_API('Z3_rcf_neq', BOOL, (_in(CONTEXT), _in(RCF_NUM), _in(RCF_NUM)))
*/
@ -191,7 +191,7 @@ extern "C" {
/**
\brief Extract the "numerator" and "denominator" of the given RCF numeral.
We have that a = n/d, moreover n and d are not represented using rational functions.
We have that \ccode{a = n/d}, moreover \c n and \c d are not represented using rational functions.
def_API('Z3_rcf_get_numerator_denominator', VOID, (_in(CONTEXT), _in(RCF_NUM), _out(RCF_NUM), _out(RCF_NUM)))
*/

View file

@ -37,9 +37,9 @@ extern "C" {
\endcode
query returns
- Z3_L_FALSE if the query is unsatisfiable.
- Z3_L_TRUE if the query is satisfiable. Obtain the answer by calling #Z3_fixedpoint_get_answer.
- Z3_L_UNDEF if the query was interrupted, timed out or otherwise failed.
- \c Z3_L_FALSE if the query is unsatisfiable.
- \c Z3_L_TRUE if the query is satisfiable. Obtain the answer by calling #Z3_fixedpoint_get_answer.
- \c Z3_L_UNDEF if the query was interrupted, timed out or otherwise failed.
def_API('Z3_fixedpoint_query_from_lvl', INT, (_in(CONTEXT), _in(FIXEDPOINT), _in(AST), _in(UINT)))
*/
@ -48,7 +48,7 @@ extern "C" {
/**
\brief Retrieve a bottom-up (from query) sequence of ground facts
The previous call to Z3_fixedpoint_query must have returned Z3_L_TRUE.
The previous call to #Z3_fixedpoint_query must have returned \c Z3_L_TRUE.
def_API('Z3_fixedpoint_get_ground_sat_answer', AST, (_in(CONTEXT), _in(FIXEDPOINT)))
*/

View file

@ -17,6 +17,7 @@ z3_add_component(ast
csp_decl_plugin.cpp
datatype_decl_plugin.cpp
decl_collector.cpp
display_dimacs.cpp
dl_decl_plugin.cpp
expr2polynomial.cpp
expr2var.cpp

View file

@ -73,11 +73,9 @@ void act_cache::init() {
}
void act_cache::dec_refs() {
map::iterator it = m_table.begin();
map::iterator end = m_table.end();
for (; it != end; ++it) {
m_manager.dec_ref((*it).m_key);
m_manager.dec_ref(UNTAG(expr*, (*it).m_value));
for (auto & kv : m_table) {
m_manager.dec_ref(kv.m_key.first);
m_manager.dec_ref(UNTAG(expr*, kv.m_value));
}
}
@ -105,18 +103,18 @@ act_cache::~act_cache() {
void act_cache::del_unused() {
unsigned sz = m_queue.size();
while (m_qhead < sz) {
expr * k = m_queue[m_qhead];
entry_t const& e = m_queue[m_qhead];
m_qhead++;
SASSERT(m_table.contains(k));
map::key_value * entry = m_table.find_core(k);
SASSERT(m_table.contains(e));
map::key_value * entry = m_table.find_core(e);
SASSERT(entry);
if (GET_TAG(entry->m_value) == 0) {
// Key k was never accessed by client code.
// That is, find(k) was never executed by client code.
m_unused--;
expr * v = entry->m_value;
m_table.erase(k);
m_manager.dec_ref(k);
m_table.erase(e);
m_manager.dec_ref(e.first);
m_manager.dec_ref(v);
break;
}
@ -135,12 +133,13 @@ void act_cache::del_unused() {
/**
\brief Insert a new entry k -> v into the cache.
*/
void act_cache::insert(expr * k, expr * v) {
void act_cache::insert(expr * k, unsigned offset, expr * v) {
SASSERT(k);
entry_t e(k, offset);
if (m_unused >= m_max_unused)
del_unused();
expr * dummy = reinterpret_cast<expr*>(1);
map::key_value & entry = m_table.insert_if_not_there(k, dummy);
map::key_value & entry = m_table.insert_if_not_there(e, dummy);
#if 0
unsigned static counter = 0;
counter++;
@ -156,7 +155,7 @@ void act_cache::insert(expr * k, expr * v) {
m_manager.inc_ref(k);
m_manager.inc_ref(v);
entry.m_value = v;
m_queue.push_back(k);
m_queue.push_back(e);
m_unused++;
DEBUG_CODE(expected_tag = 0;); // new entry
}
@ -175,7 +174,7 @@ void act_cache::insert(expr * k, expr * v) {
}
DEBUG_CODE({
expr * v2;
SASSERT(m_table.find(k, v2));
SASSERT(m_table.find(e, v2));
SASSERT(v == UNTAG(expr*, v2));
SASSERT(expected_tag == GET_TAG(v2));
});
@ -185,8 +184,9 @@ void act_cache::insert(expr * k, expr * v) {
\brief Search for key k in the cache.
If entry k -> (v, tag) is found, we set tag to 1.
*/
expr * act_cache::find(expr * k) {
map::key_value * entry = m_table.find_core(k);
expr * act_cache::find(expr * k, unsigned offset) {
entry_t e(k, offset);
map::key_value * entry = m_table.find_core(e);
if (entry == nullptr)
return nullptr;
if (GET_TAG(entry->m_value) == 0) {
@ -196,7 +196,7 @@ expr * act_cache::find(expr * k) {
m_unused--;
DEBUG_CODE({
expr * v;
SASSERT(m_table.find(k, v));
SASSERT(m_table.find(e, v));
SASSERT(GET_TAG(v) == 1);
});
}

View file

@ -26,9 +26,15 @@ Notes:
class act_cache {
ast_manager & m_manager;
typedef cmap<expr*, expr*, obj_ptr_hash<expr>, default_eq<expr*> > map;
typedef std::pair<expr*, unsigned> entry_t;
struct entry_hash {
unsigned operator()(entry_t const& e) const {
return e.first->hash() + e.second;
}
};
typedef cmap<entry_t, expr*, entry_hash, default_eq<entry_t> > map;
map m_table;
ptr_vector<expr> m_queue; // recently created queue
svector<entry_t> m_queue; // recently created queue
unsigned m_qhead;
unsigned m_unused;
unsigned m_max_unused;
@ -42,8 +48,10 @@ public:
act_cache(ast_manager & m);
act_cache(ast_manager & m, unsigned max_unused);
~act_cache();
void insert(expr * k, expr * v);
expr * find(expr * k);
void insert(expr * k, expr * v) { insert(k, 0, v); }
expr * find(expr * k) { return find(k, 0); }
void insert(expr * k, unsigned offset, expr * v);
expr * find(expr * k, unsigned offset);
void reset();
void cleanup();
unsigned size() const { return m_table.size(); }

View file

@ -571,6 +571,11 @@ func_decl * array_recognizers::get_as_array_func_decl(expr * n) const {
return to_func_decl(to_app(n)->get_decl()->get_parameter(0).get_ast());
}
func_decl * array_recognizers::get_as_array_func_decl(func_decl * f) const {
SASSERT(is_as_array(f));
return to_func_decl(f->get_parameter(0).get_ast());
}
array_util::array_util(ast_manager& m):
array_recognizers(m.mk_family_id("array")),
m_manager(m) {

View file

@ -149,7 +149,9 @@ public:
bool is_const(func_decl* f) const { return is_decl_of(f, m_fid, OP_CONST_ARRAY); }
bool is_map(func_decl* f) const { return is_decl_of(f, m_fid, OP_ARRAY_MAP); }
bool is_as_array(func_decl* f) const { return is_decl_of(f, m_fid, OP_AS_ARRAY); }
bool is_as_array(func_decl* f, func_decl*& g) const { return is_decl_of(f, m_fid, OP_AS_ARRAY) && (g = get_as_array_func_decl(f), true); }
func_decl * get_as_array_func_decl(expr * n) const;
func_decl * get_as_array_func_decl(func_decl* f) const;
};
class array_util : public array_recognizers {

View file

@ -1407,6 +1407,7 @@ ast_manager::ast_manager(ast_manager const & src, bool disable_proofs):
m_format_manager = alloc(ast_manager, PGM_DISABLED, m_trace_stream, true);
init();
copy_families_plugins(src);
update_fresh_id(src);
}
void ast_manager::update_fresh_id(ast_manager const& m) {
@ -2156,7 +2157,6 @@ app * ast_manager::mk_app_core(func_decl * decl, unsigned num_args, expr * const
app * new_node = nullptr;
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);

View file

@ -238,7 +238,7 @@ format * smt2_pp_environment::pp_float_literal(app * t, bool use_bv_lits, bool u
string_buffer<> buf;
VERIFY(get_futil().is_numeral(t, v));
if (fm.is_nan(v)) {
buf << "(_ NaN " << v.get().get_ebits() << " " << v.get().get_sbits() << ")";
buf << "(_ NaN " << v.get().get_ebits() << " " << v.get().get_sbits() << ")";
return mk_string(m, buf.c_str());
}
else if (fm.is_pinf(v)) {

View file

@ -399,12 +399,12 @@ class smt_printer {
pp_marked_expr(n->get_arg(0));
m_out << ") (_ bv1 1))";
}
else if (m_manager.is_label(n, pos, names) && names.size() >= 1) {
else if (m_manager.is_label(n, pos, names) && !names.empty()) {
m_out << "(! ";
pp_marked_expr(n->get_arg(0));
m_out << (pos?":lblpos":":lblneg") << " " << m_renaming.get_symbol(names[0], false) << ")";
}
else if (m_manager.is_label_lit(n, names) && names.size() >= 1) {
else if (m_manager.is_label_lit(n, names) && !names.empty()) {
m_out << "(! true :lblpos " << m_renaming.get_symbol(names[0], false) << ")";
}
else if (num_args == 0) {
@ -952,7 +952,7 @@ void ast_smt_pp::display_smt2(std::ostream& strm, expr* n) {
if (m_logic != symbol::null && m_logic != symbol("")) {
strm << "(set-logic " << m_logic << ")\n";
}
if (m_attributes.size() > 0) {
if (!m_attributes.empty()) {
strm << "; " << m_attributes.c_str();
}

View file

@ -558,11 +558,15 @@ func_decl * bv_decl_plugin::mk_func_decl(decl_kind k, unsigned num_parameters, p
case OP_ROTATE_LEFT:
if (arity != 1)
m_manager->raise_exception("rotate left expects one argument");
if (num_parameters != 1 || !parameters[0].is_int())
m_manager->raise_exception("rotate left expects one integer parameter");
return m_manager->mk_func_decl(m_rotate_left_sym, arity, domain, domain[0],
func_decl_info(m_family_id, k, num_parameters, parameters));
case OP_ROTATE_RIGHT:
if (arity != 1)
m_manager->raise_exception("rotate right expects one argument");
if (num_parameters != 1 || !parameters[0].is_int())
m_manager->raise_exception("rotate right expects one integer parameter");
return m_manager->mk_func_decl(m_rotate_right_sym, arity, domain, domain[0],
func_decl_info(m_family_id, k, num_parameters, parameters));
case OP_REPEAT:

View file

@ -148,7 +148,7 @@ public:
bool is_resource(expr* e, unsigned& r);
bool is_makespan(expr* e, unsigned& r);
bool is_add_resource_available(expr * e, expr *& res, unsigned& loadpct, unsigned& cap_time, uint64_t& start, uint64_t& end, svector<symbol>& properites);
bool is_add_job_resource(expr * e, expr *& job, expr*& res, unsigned& loadpct, uint64_t& capacity, uint64_t& end, svector<symbol>& properites);
bool is_add_job_resource(expr * e, expr *& job, expr*& res, unsigned& loadpct, uint64_t& capacity, uint64_t& finite_capacity_end, svector<symbol>& properites);
bool is_set_preemptable(expr* e, expr *& job);
bool is_model(expr* e) const { return is_app_of(e, m_fid, OP_JS_MODEL); }
bool is_js_properties(expr* e, svector<symbol>& properties);

View file

@ -143,7 +143,77 @@ namespace datatype {
}
return r;
}
size* size::mk_power(size* a1, size* a2) { return alloc(power, a1, a2); }
size* size::mk_power(size* a1, size* a2) {
return alloc(power, a1, a2);
}
sort_size plus::eval(obj_map<sort, sort_size> const& S) {
rational r(0);
ptr_vector<size> todo;
todo.push_back(m_arg1);
todo.push_back(m_arg2);
while (!todo.empty()) {
size* s = todo.back();
todo.pop_back();
plus* p = dynamic_cast<plus*>(s);
if (p) {
todo.push_back(p->m_arg1);
todo.push_back(p->m_arg2);
}
else {
sort_size sz = s->eval(S);
if (sz.is_infinite()) return sz;
if (sz.is_very_big()) return sz;
r += rational(sz.size(), rational::ui64());
}
}
return sort_size(r);
}
size* plus::subst(obj_map<sort,size*>& S) {
return mk_plus(m_arg1->subst(S), m_arg2->subst(S));
}
sort_size times::eval(obj_map<sort, sort_size> const& S) {
sort_size s1 = m_arg1->eval(S);
sort_size s2 = m_arg2->eval(S);
if (s1.is_infinite()) return s1;
if (s2.is_infinite()) return s2;
if (s1.is_very_big()) return s1;
if (s2.is_very_big()) return s2;
rational r = rational(s1.size(), rational::ui64()) * rational(s2.size(), rational::ui64());
return sort_size(r);
}
size* times::subst(obj_map<sort,size*>& S) {
return mk_times(m_arg1->subst(S), m_arg2->subst(S));
}
sort_size power::eval(obj_map<sort, sort_size> const& S) {
sort_size s1 = m_arg1->eval(S);
sort_size s2 = m_arg2->eval(S);
// s1^s2
if (s1.is_infinite()) return s1;
if (s2.is_infinite()) return s2;
if (s1.is_very_big()) return s1;
if (s2.is_very_big()) return s2;
if (s1.size() == 1) return s1;
if (s2.size() == 1) return s1;
if (s1.size() > (2 << 20) || s2.size() > 10) return sort_size::mk_very_big();
rational r = ::power(rational(s1.size(), rational::ui64()), static_cast<unsigned>(s2.size()));
return sort_size(r);
}
size* power::subst(obj_map<sort,size*>& S) {
return mk_power(m_arg1->subst(S), m_arg2->subst(S));
}
size* sparam::subst(obj_map<sort, size*>& S) {
return S[m_param];
}
}
namespace decl {
@ -625,13 +695,14 @@ namespace datatype {
param_size::size* sz;
obj_map<sort, param_size::size*> S;
unsigned n = get_datatype_num_parameter_sorts(s);
def & d = get_def(s->get_name());
SASSERT(n == d.params().size());
for (unsigned i = 0; i < n; ++i) {
sort* ps = get_datatype_parameter_sort(s, i);
sz = get_sort_size(params, ps);
sz->inc_ref();
S.insert(ps, sz);
}
def & d = get_def(s->get_name());
sz->inc_ref();
S.insert(d.params().get(i), sz);
}
sz = d.sort_size()->subst(S);
for (auto & kv : S) {
kv.m_value->dec_ref();
@ -708,7 +779,7 @@ namespace datatype {
continue;
}
ptr_vector<param_size::size> s_add;
ptr_vector<param_size::size> s_add;
for (constructor const* c : d) {
ptr_vector<param_size::size> s_mul;
for (accessor const* a : *c) {
@ -723,7 +794,7 @@ namespace datatype {
/**
\brief Return true if the inductive datatype is well-founded.
Pre-condition: The given argument constains the parameters of an inductive datatype.
Pre-condition: The given argument constrains the parameters of an inductive datatype.
*/
bool util::is_well_founded(unsigned num_types, sort* const* sorts) {
buffer<bool> well_founded(num_types, false);

View file

@ -132,71 +132,28 @@ namespace datatype {
size* m_arg1, *m_arg2;
plus(size* a1, size* a2): m_arg1(a1), m_arg2(a2) { a1->inc_ref(); a2->inc_ref();}
~plus() override { m_arg1->dec_ref(); m_arg2->dec_ref(); }
size* subst(obj_map<sort,size*>& S) override { return mk_plus(m_arg1->subst(S), m_arg2->subst(S)); }
sort_size eval(obj_map<sort, sort_size> const& S) override {
rational r(0);
ptr_vector<size> todo;
todo.push_back(m_arg1);
todo.push_back(m_arg2);
while (!todo.empty()) {
size* s = todo.back();
todo.pop_back();
plus* p = dynamic_cast<plus*>(s);
if (p) {
todo.push_back(p->m_arg1);
todo.push_back(p->m_arg2);
}
else {
sort_size sz = s->eval(S);
if (sz.is_infinite()) return sz;
if (sz.is_very_big()) return sz;
r += rational(sz.size(), rational::ui64());
}
}
return sort_size(r);
}
size* subst(obj_map<sort,size*>& S) override;
sort_size eval(obj_map<sort, sort_size> const& S) override;
};
struct times : public size {
size* m_arg1, *m_arg2;
times(size* a1, size* a2): m_arg1(a1), m_arg2(a2) { a1->inc_ref(); a2->inc_ref(); }
~times() override { m_arg1->dec_ref(); m_arg2->dec_ref(); }
size* subst(obj_map<sort,size*>& S) override { return mk_times(m_arg1->subst(S), m_arg2->subst(S)); }
sort_size eval(obj_map<sort, sort_size> const& S) override {
sort_size s1 = m_arg1->eval(S);
sort_size s2 = m_arg2->eval(S);
if (s1.is_infinite()) return s1;
if (s2.is_infinite()) return s2;
if (s1.is_very_big()) return s1;
if (s2.is_very_big()) return s2;
rational r = rational(s1.size(), rational::ui64()) * rational(s2.size(), rational::ui64());
return sort_size(r);
}
size* subst(obj_map<sort,size*>& S) override;
sort_size eval(obj_map<sort, sort_size> const& S) override;
};
struct power : public size {
size* m_arg1, *m_arg2;
power(size* a1, size* a2): m_arg1(a1), m_arg2(a2) { a1->inc_ref(); a2->inc_ref(); }
~power() override { m_arg1->dec_ref(); m_arg2->dec_ref(); }
size* subst(obj_map<sort,size*>& S) override { return mk_power(m_arg1->subst(S), m_arg2->subst(S)); }
sort_size eval(obj_map<sort, sort_size> const& S) override {
sort_size s1 = m_arg1->eval(S);
sort_size s2 = m_arg2->eval(S);
// s1^s2
if (s1.is_infinite()) return s1;
if (s2.is_infinite()) return s2;
if (s1.is_very_big()) return s1;
if (s2.is_very_big()) return s2;
if (s1.size() == 1) return s1;
if (s2.size() == 1) return s1;
if (s1.size() > (2 << 20) || s2.size() > 10) return sort_size::mk_very_big();
rational r = ::power(rational(s1.size(), rational::ui64()), static_cast<unsigned>(s2.size()));
return sort_size(r);
}
size* subst(obj_map<sort,size*>& S) override;
sort_size eval(obj_map<sort, sort_size> const& S) override;
};
struct sparam : public size {
sort_ref m_param;
sparam(sort_ref& p): m_param(p) {}
~sparam() override {}
size* subst(obj_map<sort,size*>& S) override { return S[m_param]; }
size* subst(obj_map<sort, size*>& S) override;
sort_size eval(obj_map<sort, sort_size> const& S) override { return S[m_param]; }
};
};

View file

@ -0,0 +1,81 @@
/*++
Copyright (c) 2019 Microsoft Corporation
Module Name:
display_dimacs.h
Abstract:
Display expressions in DIMACS format.
Author:
Nikolaj Bjorner (nbjorner0 2019-01-24
Revision History:
--*/
#include "ast.h"
#include "display_dimacs.h"
std::ostream& display_dimacs(std::ostream& out, expr_ref_vector const& fmls) {
ast_manager& m = fmls.m();
unsigned_vector expr2var;
ptr_vector<expr> exprs;
unsigned num_vars = 0;
unsigned num_cls = fmls.size();
for (expr * f : fmls) {
unsigned num_lits;
expr * const * lits;
if (m.is_or(f)) {
num_lits = to_app(f)->get_num_args();
lits = to_app(f)->get_args();
}
else {
num_lits = 1;
lits = &f;
}
for (unsigned j = 0; j < num_lits; j++) {
expr * l = lits[j];
if (m.is_not(l))
l = to_app(l)->get_arg(0);
if (expr2var.get(l->get_id(), UINT_MAX) == UINT_MAX) {
num_vars++;
expr2var.setx(l->get_id(), num_vars, UINT_MAX);
exprs.setx(l->get_id(), l, nullptr);
}
}
}
out << "p cnf " << num_vars << " " << num_cls << "\n";
for (expr* f : fmls) {
unsigned num_lits;
expr * const * lits;
if (m.is_or(f)) {
num_lits = to_app(f)->get_num_args();
lits = to_app(f)->get_args();
}
else {
num_lits = 1;
lits = &f;
}
for (unsigned j = 0; j < num_lits; j++) {
expr * l = lits[j];
if (m.is_not(l)) {
out << "-";
l = to_app(l)->get_arg(0);
}
SASSERT(exprs[l->get_id()]);
out << expr2var[l->get_id()] << " ";
}
out << "0\n";
}
for (expr* e : exprs) {
if (e && is_app(e)) {
symbol const& n = to_app(e)->get_decl()->get_name();
out << "c " << expr2var[e->get_id()] << " " << n << "\n";
}
}
return out;
}

26
src/ast/display_dimacs.h Normal file
View file

@ -0,0 +1,26 @@
/*++
Copyright (c) 2019 Microsoft Corporation
Module Name:
display_dimacs.h
Abstract:
Display expressions in DIMACS format.
Author:
Nikolaj Bjorner (nbjorner0 2019-01-24
Revision History:
--*/
#ifndef DISPLAY_DIMACS_H_
#define DISPLAY_DIMACS_H_
#include "ast.h"
std::ostream& display_dimacs(std::ostream& out, expr_ref_vector const& fmls);
#endif /* DISPLAY_DIMACS_H__ */

View file

@ -147,7 +147,7 @@ namespace datalog {
for (unsigned i = 0; i < n; ++i) {
parameter const& p = r->get_parameter(i);
if (!p.is_ast() || !is_sort(p.get_ast())) {
m_manager->raise_exception("exptected sort parameter");
m_manager->raise_exception("expected sort parameter");
return false;
}
sorts.push_back(to_sort(p.get_ast()));
@ -185,7 +185,7 @@ namespace datalog {
verbose_stream() << "Domain: " << mk_pp(domain[0], m) << "\n" <<
mk_pp(sorts[i], m) << "\n" <<
mk_pp(domain[i+1], m) << "\n";);
m_manager->raise_exception("sort miss-match for relational access");
m_manager->raise_exception("sort mismatch for relational access");
return nullptr;
}
}
@ -252,7 +252,7 @@ namespace datalog {
func_decl * dl_decl_plugin::mk_unionw(decl_kind k, sort* s1, sort* s2) {
ast_manager& m = *m_manager;
if (s1 != s2) {
m_manager->raise_exception("sort miss-match for arguments to union");
m_manager->raise_exception("sort mismatch for arguments to union");
return nullptr;
}
if (!is_rel_sort(s1)) {
@ -298,7 +298,7 @@ namespace datalog {
return nullptr;
}
if (sorts[idx] != m.get_sort(e)) {
m_manager->raise_exception("sort miss-match in filter");
m_manager->raise_exception("sort mismatch in filter");
return nullptr;
}
break;
@ -391,7 +391,7 @@ namespace datalog {
return nullptr;
}
if (sorts1[i1] != sorts2[i2]) {
m_manager->raise_exception("sort miss-match in join");
m_manager->raise_exception("sort mismatch in join");
return nullptr;
}
}
@ -435,7 +435,7 @@ namespace datalog {
return nullptr;
}
if (sorts1[i1] != sorts2[i2]) {
m_manager->raise_exception("sort miss-match in join");
m_manager->raise_exception("sort mismatch in join");
return nullptr;
}
}

View file

@ -436,7 +436,7 @@ struct expr2polynomial::imp {
margs.push_back(t);
}
}
if (margs.size() == 0) {
if (margs.empty()) {
args.push_back(m_autil.mk_numeral(rational(1), is_int));
}
else if (margs.size() == 1) {
@ -447,7 +447,7 @@ struct expr2polynomial::imp {
}
}
if (args.size() == 0) {
if (args.empty()) {
r = m_autil.mk_numeral(rational(0), is_int);
}
else if (args.size() == 1) {

View file

@ -29,8 +29,17 @@ void expr2var::insert(expr * n, var v) {
TRACE("expr2var", tout << "interpreted:\n" << mk_ismt2_pp(n, m()) << "\n";);
m_interpreted_vars = true;
}
m().inc_ref(n);
m_mapping.insert(n, v);
unsigned idx = m_id2map.get(n->get_id(), UINT_MAX);
if (idx == UINT_MAX) {
m().inc_ref(n);
idx = m_mapping.size();
m_mapping.push_back(key_value(n, v));
m_id2map.setx(n->get_id(), idx, UINT_MAX);
}
else {
m_mapping[idx] = key_value(n, v);
}
m_recent_exprs.push_back(n);
}
@ -40,20 +49,22 @@ expr2var::expr2var(ast_manager & m):
}
expr2var::~expr2var() {
dec_ref_map_keys(m(), m_mapping);
for (auto & kv : m_mapping) {
m().dec_ref(kv.m_key);
}
}
expr2var::var expr2var::to_var(expr * n) const {
var v = UINT_MAX;
m_mapping.find(n, v);
var v = m_id2map.get(n->get_id(), UINT_MAX);
if (v != UINT_MAX) {
v = m_mapping[v].m_value;
}
return v;
}
void expr2var::display(std::ostream & out) const {
obj_map<expr, var>::iterator it = m_mapping.begin();
obj_map<expr, var>::iterator end = m_mapping.end();
for (; it != end; ++it) {
out << mk_ismt2_pp(it->m_key, m()) << " -> " << it->m_value << "\n";
for (auto const& kv : m_mapping) {
out << mk_ismt2_pp(kv.m_key, m()) << " -> " << kv.m_value << "\n";
}
}
@ -68,8 +79,11 @@ void expr2var::mk_inv(expr_ref_vector & var2expr) const {
}
void expr2var::reset() {
dec_ref_map_keys(m(), m_mapping);
SASSERT(m_mapping.empty());
for (auto & kv : m_mapping) {
m().dec_ref(kv.m_key);
}
m_mapping.reset();
m_id2map.reset();
m_recent_exprs.reset();
m_recent_lim.reset();
m_interpreted_vars = false;
@ -83,8 +97,15 @@ void expr2var::pop(unsigned num_scopes) {
if (num_scopes > 0) {
unsigned sz = m_recent_lim[m_recent_lim.size() - num_scopes];
for (unsigned i = sz; i < m_recent_exprs.size(); ++i) {
m_mapping.erase(m_recent_exprs[i]);
m().dec_ref(m_recent_exprs[i]);
expr* n = m_recent_exprs[i];
unsigned idx = m_id2map[n->get_id()];
if (idx + 1 != m_mapping.size()) {
m_id2map[m_mapping.back().m_key->get_id()] = idx;
m_mapping[idx] = m_mapping.back();
}
m_id2map[n->get_id()] = UINT_MAX;
m_mapping.pop_back();
m().dec_ref(n);
}
m_recent_exprs.shrink(sz);
m_recent_lim.shrink(m_recent_lim.size() - num_scopes);

View file

@ -32,12 +32,14 @@ Notes:
class expr2var {
public:
typedef unsigned var;
typedef obj_map<expr, var> expr2var_mapping;
typedef expr2var_mapping::iterator iterator;
typedef obj_map<expr, var>::key_data key_value;
typedef key_value const* iterator;
typedef ptr_vector<expr>::const_iterator recent_iterator;
protected:
ast_manager & m_manager;
expr2var_mapping m_mapping;
unsigned_vector m_id2map;
svector<key_value> m_mapping;
ptr_vector<expr> m_recent_exprs;
unsigned_vector m_recent_lim;
bool m_interpreted_vars;
@ -51,7 +53,7 @@ public:
var to_var(expr * n) const;
bool is_var(expr * n) const { return m_mapping.contains(n); }
bool is_var(expr * n) const { return m_id2map.get(n->get_id(), UINT_MAX) != UINT_MAX; }
void display(std::ostream & out) const;

View file

@ -3300,11 +3300,11 @@ void fpa2bv_converter::mk_to_bv(func_decl * f, unsigned num, expr * const * args
ll = m_bv_util.mk_sign_extend(3, m_bv_util.mk_concat(bv1, m_bv_util.mk_numeral(0, bv_sz-1)));
ul = m_bv_util.mk_zero_extend(4, m_bv_util.mk_bv_neg(m_bv_util.mk_numeral(1, bv_sz-1)));
ovfl = m.mk_or(ovfl, m_bv_util.mk_sle(pre_rounded, m_bv_util.mk_bv_neg(m_bv_util.mk_numeral(1, bv_sz + 3))));
pre_rounded = m.mk_ite(x_is_neg, m_bv_util.mk_bv_neg(pre_rounded), pre_rounded);
in_range = m.mk_and(m.mk_not(ovfl),
m_bv_util.mk_sle(ll, pre_rounded),
m_bv_util.mk_sle(pre_rounded, ul));
dbg_decouple("fpa2bv_to_bv_in_range_ll", ll);
pre_rounded = m.mk_ite(x_is_neg, m_bv_util.mk_bv_neg(pre_rounded), pre_rounded);
}
dbg_decouple("fpa2bv_to_bv_in_range_ovfl", ovfl);
dbg_decouple("fpa2bv_to_bv_in_range_ul", ul);

View file

@ -594,7 +594,6 @@ bool pattern_inference_cfg::reduce_quantifier(
unsigned new_weight;
if (m_database.match_quantifier(q, new_patterns, new_weight)) {
DEBUG_CODE(for (unsigned i = 0; i < new_patterns.size(); i++) { SASSERT(is_well_sorted(m, new_patterns.get(i))); });
quantifier_ref new_q(m);
if (q->get_num_patterns() > 0) {
// just update the weight...
TRACE("pattern_inference", tout << "updating weight to: " << new_weight << "\n" << mk_pp(q, m) << "\n";);
@ -604,10 +603,10 @@ bool pattern_inference_cfg::reduce_quantifier(
quantifier_ref tmp(m);
tmp = m.update_quantifier(q, new_patterns.size(), (expr**) new_patterns.c_ptr(), q->get_expr());
result = m.update_quantifier_weight(tmp, new_weight);
TRACE("pattern_inference", tout << "found patterns in database, weight: " << new_weight << "\n" << mk_pp(new_q, m) << "\n";);
TRACE("pattern_inference", tout << "found patterns in database, weight: " << new_weight << "\n" << mk_pp(result, m) << "\n";);
}
if (m.proofs_enabled())
result_pr = m.mk_rewrite(q, new_q);
result_pr = m.mk_rewrite(q, result);
return true;
}
}

View file

@ -238,7 +238,7 @@ class reduce_hypotheses {
{ args.push_back(fact); }
if (args.size() == 0) { return pf; }
if (args.empty()) { return pf; }
else if (args.size() == 1) {
lemma = args.get(0);
} else {

View file

@ -68,7 +68,7 @@ namespace recfun {
struct ite_find_p : public i_expr_pred {
ast_manager & m;
ite_find_p(ast_manager & m) : m(m) {}
virtual bool operator()(expr * e) { return m.is_ite(e); }
bool operator()(expr * e) override { return m.is_ite(e); }
};
// ignore ites under quantifiers.
// this is redundant as the code
@ -331,7 +331,7 @@ namespace recfun {
struct is_imm_pred : is_immediate_pred {
util & u;
is_imm_pred(util & u) : u(u) {}
bool operator()(expr * rhs) {
bool operator()(expr * rhs) override {
// find an `app` that is an application of a defined function
struct find : public i_expr_pred {
util & u;

View file

@ -56,7 +56,7 @@ namespace recfun {
friend class def;
func_decl_ref m_pred; //<! predicate used for this case
expr_ref_vector m_guards; //<! conjunction that is equivalent to this case
expr_ref m_rhs; //<! if guard is true, `f(t1tn) = rhs` holds
expr_ref m_rhs; //<! if guard is true, `f(t1...tn) = rhs` holds
def * m_def; //<! definition this is a part of
bool m_immediate; //<! does `rhs` contain no defined_fun/case_pred?

View file

@ -19,6 +19,7 @@ z3_add_component(rewriter
factor_equivs.cpp
factor_rewriter.cpp
fpa_rewriter.cpp
hoist_rewriter.cpp
inj_axiom.cpp
label_rewriter.cpp
maximize_ac_sharing.cpp

View file

@ -861,7 +861,8 @@ bool arith_rewriter::divides(expr* num, expr* den, expr_ref& result) {
if (m_util.is_numeral(arg, num_r)) num_e = arg;
}
for (expr* arg : args2) {
if (mark.is_marked(arg)) {
// dont remove divisor on (div (* -1 x) (* -1 y)) because rewriting would diverge.
if (mark.is_marked(arg) && (!m_util.is_numeral(arg, num_r) || !num_r.is_minus_one())) {
result = remove_divisor(arg, num, den);
return true;
}
@ -900,7 +901,14 @@ expr_ref arith_rewriter::remove_divisor(expr* arg, expr* num, expr* den) {
expr_ref zero(m_util.mk_int(0), m());
num = args1.empty() ? m_util.mk_int(1) : m_util.mk_mul(args1.size(), args1.c_ptr());
den = args2.empty() ? m_util.mk_int(1) : m_util.mk_mul(args2.size(), args2.c_ptr());
return expr_ref(m().mk_ite(m().mk_eq(zero, arg), m_util.mk_idiv(zero, zero), m_util.mk_idiv(num, den)), m());
expr_ref d(m_util.mk_idiv(num, den), m());
expr_ref nd(m_util.mk_idiv(m_util.mk_uminus(num), m_util.mk_uminus(den)), m());
return expr_ref(m().mk_ite(m().mk_eq(zero, arg),
m_util.mk_idiv(zero, zero),
m().mk_ite(m_util.mk_ge(arg, zero),
d,
nd)),
m());
}
void arith_rewriter::flat_mul(expr* e, ptr_buffer<expr>& args) {

View file

@ -75,9 +75,23 @@ bool bit_blaster_tpl<Cfg>::is_minus_one(unsigned sz, expr * const * bits) const
static void _num2bits(ast_manager & m, rational const & v, unsigned sz, expr_ref_vector & out_bits) {
SASSERT(v.is_nonneg());
rational aux = v;
rational two(2);
rational two(2), base32(1ull << 32ull, rational::ui64());
for (unsigned i = 0; i < sz; i++) {
if ((aux % two).is_zero())
if (i + 32 < sz) {
unsigned u = (aux % base32).get_unsigned();
for (unsigned j = 0; j < 32; ++j) {
if (0 != (u & (1 << j))) {
out_bits.push_back(m.mk_true());
}
else {
out_bits.push_back(m.mk_false());
}
}
aux = div(aux, base32);
i += 31;
continue;
}
else if ((aux % two).is_zero())
out_bits.push_back(m.mk_false());
else
out_bits.push_back(m.mk_true());

View file

@ -628,7 +628,7 @@ bool bv_bounds::is_sat_core(app * v) {
numeral new_hi = lower - one;
numeral ptr = lower;
if (has_neg_intervals) {
SASSERT(negative_intervals != NULL);
SASSERT(negative_intervals != nullptr);
std::sort(negative_intervals->begin(), negative_intervals->end(), interval_comp);
intervals::const_iterator e = negative_intervals->end();
for (intervals::const_iterator i = negative_intervals->begin(); i != e; ++i) {

View file

@ -196,6 +196,9 @@ br_status bv_rewriter::mk_app_core(func_decl * f, unsigned num_args, expr * cons
return mk_bv_comp(args[0], args[1], result);
case OP_MKBV:
return mk_mkbv(num_args, args, result);
case OP_BIT2BOOL:
SASSERT(num_args == 1);
return mk_bit2bool(args[0], f->get_parameter(0).get_int(), result);
case OP_BSMUL_NO_OVFL:
return mk_bvsmul_no_overflow(num_args, args, result);
case OP_BUMUL_NO_OVFL:
@ -779,10 +782,11 @@ br_status bv_rewriter::mk_extract(unsigned high, unsigned low, expr * arg, expr_
}
}
if (m().is_ite(arg)) {
result = m().mk_ite(to_app(arg)->get_arg(0),
m_mk_extract(high, low, to_app(arg)->get_arg(1)),
m_mk_extract(high, low, to_app(arg)->get_arg(2)));
expr* c = nullptr, *t = nullptr, *e = nullptr;
if (m().is_ite(arg, c, t, e) &&
(t->get_ref_count() == 1 || !m().is_ite(t)) &&
(e->get_ref_count() == 1 || !m().is_ite(e))) {
result = m().mk_ite(c, m_mk_extract(high, low, t), m_mk_extract(high, low, e));
return BR_REWRITE2;
}
@ -2202,6 +2206,19 @@ br_status bv_rewriter::mk_bv_mul(unsigned num_args, expr * const * args, expr_re
return st;
}
br_status bv_rewriter::mk_bit2bool(expr * n, int idx, expr_ref & result) {
rational v, bit;
unsigned sz = 0;
if (!is_numeral(n, v, sz))
return BR_FAILED;
if (idx < 0 || idx >= static_cast<int>(sz))
return BR_FAILED;
div(v, rational::power_of_two(idx), bit);
mod(bit, rational(2), bit);
result = m().mk_bool_val(bit.is_one());
return BR_DONE;
}
br_status bv_rewriter::mk_bit2bool(expr * lhs, expr * rhs, expr_ref & result) {
unsigned sz = get_bv_size(lhs);
if (sz != 1)

View file

@ -134,6 +134,7 @@ class bv_rewriter : public poly_rewriter<bv_rewriter_core> {
br_status mk_bv_redand(expr * arg, expr_ref & result);
br_status mk_bv_comp(expr * arg1, expr * arg2, expr_ref & result);
br_status mk_bit2bool(expr * lhs, expr * rhs, expr_ref & result);
br_status mk_bit2bool(expr * lhs, int idx, expr_ref & result);
br_status mk_blast_eq_value(expr * lhs, expr * rhs, expr_ref & result);
br_status mk_eq_concat(expr * lhs, expr * rhs, expr_ref & result);
br_status mk_mkbv(unsigned num, expr * const * args, expr_ref & result);

View file

@ -364,7 +364,7 @@ struct bv_trailing::imp {
}
void reset_cache(const unsigned condition) {
SASSERT(m_count_cache[0] == NULL);
SASSERT(m_count_cache[0] == nullptr);
for (unsigned i = 1; i <= TRAILING_DEPTH; ++i) {
if (m_count_cache[i] == nullptr) continue;
TRACE("bv-trailing", tout << "may reset cache " << i << " " << condition << "\n";);

View file

@ -374,13 +374,11 @@ void der::apply_substitution(quantifier * q, expr_ref & r) {
expr_ref_buffer new_patterns(m_manager);
expr_ref_buffer new_no_patterns(m_manager);
for (unsigned j = 0; j < q->get_num_patterns(); j++) {
expr_ref new_pat = m_subst(q->get_pattern(j), m_subst_map.size(), m_subst_map.c_ptr());
new_patterns.push_back(new_pat);
new_patterns.push_back(m_subst(q->get_pattern(j), m_subst_map.size(), m_subst_map.c_ptr()));
}
for (unsigned j = 0; j < q->get_num_no_patterns(); j++) {
expr_ref new_nopat = m_subst(q->get_no_pattern(j), m_subst_map.size(), m_subst_map.c_ptr());
new_no_patterns.push_back(new_nopat);
new_no_patterns.push_back(m_subst(q->get_no_pattern(j), m_subst_map.size(), m_subst_map.c_ptr()));
}
r = m_manager.update_quantifier(q, new_patterns.size(), new_patterns.c_ptr(),

View file

@ -126,8 +126,7 @@ void distribute_forall::reduce1_quantifier(quantifier * q) {
br.mk_not(arg, not_arg);
quantifier_ref tmp_q(m_manager);
tmp_q = m_manager.update_quantifier(q, not_arg);
expr_ref new_q = elim_unused_vars(m_manager, tmp_q, params_ref());
new_args.push_back(new_q);
new_args.push_back(elim_unused_vars(m_manager, tmp_q, params_ref()));
}
expr_ref result(m_manager);
// m_bsimp.mk_and actually constructs a (not (or ...)) formula,

View file

@ -0,0 +1,201 @@
/*++
Copyright (c) 2019 Microsoft Corporation
Module Name:
hoist_rewriter.cpp
Abstract:
Hoist predicates over disjunctions
Author:
Nikolaj Bjorner (nbjorner) 2019-2-4
Notes:
--*/
#include "ast/rewriter/hoist_rewriter.h"
#include "ast/ast_util.h"
#include "ast/rewriter/expr_safe_replace.h"
#include "ast/ast_pp.h"
hoist_rewriter::hoist_rewriter(ast_manager & m, params_ref const & p):
m_manager(m), m_args1(m), m_args2(m) {
updt_params(p);
}
br_status hoist_rewriter::mk_or(unsigned num_args, expr * const * es, expr_ref & result) {
if (num_args < 2) {
return BR_FAILED;
}
for (unsigned i = 0; i < num_args; ++i) {
if (!is_and(es[i], nullptr)) {
return BR_FAILED;
}
}
bool turn = false;
m_preds1.reset();
m_preds2.reset();
m_uf1.reset();
m_uf2.reset();
m_expr2var.reset();
m_var2expr.reset();
basic_union_find* uf[2] = { &m_uf1, &m_uf2 };
obj_hashtable<expr>* preds[2] = { &m_preds1, &m_preds2 };
expr_ref_vector* args[2] = { &m_args1, &m_args2 };
VERIFY(is_and(es[0], args[turn]));
expr* e1, *e2;
for (expr* e : *(args[turn])) {
if (m().is_eq(e, e1, e2)) {
(*uf)[turn].merge(mk_var(e1), mk_var(e2));
}
else {
(*preds)[turn].insert(e);
}
}
unsigned round = 0;
for (unsigned j = 1; j < num_args; ++j) {
++round;
m_es.reset();
m_mark.reset();
bool last = turn;
turn = !turn;
(*preds)[turn].reset();
reset(m_uf0);
VERIFY(is_and(es[j], args[turn]));
for (expr* e : *args[turn]) {
if (m().is_eq(e, e1, e2)) {
m_es.push_back(e1);
m_uf0.merge(mk_var(e1), mk_var(e2));
}
else if ((*preds)[last].contains(e)) {
(*preds)[turn].insert(e);
}
}
if ((*preds)[turn].empty() && m_es.empty()) {
return BR_FAILED;
}
m_eqs.reset();
for (expr* e : m_es) {
if (m_mark.is_marked(e)) {
continue;
}
unsigned u = mk_var(e);
unsigned v = u;
m_roots.reset();
do {
m_mark.mark(e);
unsigned r = (*uf)[last].find(v);
if (m_roots.find(r, e2)) {
m_eqs.push_back(std::make_pair(e, e2));
}
else {
m_roots.insert(r, e);
}
v = m_uf0.next(v);
e = mk_expr(v);
}
while (u != v);
}
reset((*uf)[turn]);
for (auto const& p : m_eqs) {
(*uf)[turn].merge(mk_var(p.first), mk_var(p.second));
}
if ((*preds)[turn].empty() && m_eqs.empty()) {
return BR_FAILED;
}
}
// p & eqs & (or fmls)
expr_ref_vector fmls(m()), ors(m());
expr_safe_replace subst(m());
for (expr * p : (*preds)[turn]) {
expr* q = nullptr;
if (m().is_not(p, q)) {
subst.insert(q, m().mk_false());
}
else {
subst.insert(p, m().mk_true());
}
fmls.push_back(p);
}
for (auto const& p : m_eqs) {
subst.insert(p.first, p.second);
fmls.push_back(m().mk_eq(p.first, p.second));
}
for (unsigned i = 0; i < num_args; ++i) {
expr_ref tmp(m());
subst(es[i], tmp);
ors.push_back(tmp);
}
fmls.push_back(m().mk_or(ors.size(), ors.c_ptr()));
result = m().mk_and(fmls.size(), fmls.c_ptr());
TRACE("hoist",
for (unsigned i = 0; i < num_args; ++i) {
tout << mk_pp(es[i], m()) << "\n";
}
tout << "=>\n";
tout << result << "\n";);
return BR_DONE;
}
unsigned hoist_rewriter::mk_var(expr* e) {
unsigned v = 0;
if (m_expr2var.find(e, v)) {
return v;
}
v = m_uf1.mk_var();
v = m_uf2.mk_var();
SASSERT(v == m_var2expr.size());
m_expr2var.insert(e, v);
m_var2expr.push_back(e);
return v;
}
br_status hoist_rewriter::mk_app_core(func_decl * f, unsigned num_args, expr * const * args, expr_ref & result) {
switch (f->get_decl_kind()) {
case OP_OR:
return mk_or(num_args, args, result);
default:
return BR_FAILED;
}
}
bool hoist_rewriter::is_and(expr * e, expr_ref_vector* args) {
if (m().is_and(e)) {
if (args) {
args->reset();
args->append(to_app(e)->get_num_args(), to_app(e)->get_args());
}
return true;
}
if (m().is_not(e, e) && m().is_or(e)) {
if (args) {
args->reset();
for (expr* arg : *to_app(e)) {
args->push_back(::mk_not(m(), arg));
}
}
return true;
}
return false;
}
void hoist_rewriter::reset(basic_union_find& uf) {
uf.reset();
for (expr* e : m_var2expr) {
(void)e;
uf.mk_var();
}
}

View file

@ -0,0 +1,80 @@
/*++
Copyright (c) 2019 Microsoft Corporation
Module Name:
hoist_rewriter.h
Abstract:
Hoist predicates over disjunctions
Author:
Nikolaj Bjorner (nbjorner) 2019-2-4
Notes:
--*/
#ifndef HOIST_REWRITER_H_
#define HOIST_REWRITER_H_
#include "ast/ast.h"
#include "ast/rewriter/rewriter.h"
#include "util/params.h"
#include "util/union_find.h"
#include "util/obj_hashtable.h"
class hoist_rewriter {
ast_manager & m_manager;
expr_ref_vector m_args1, m_args2;
obj_hashtable<expr> m_preds1, m_preds2;
basic_union_find m_uf1, m_uf2, m_uf0;
ptr_vector<expr> m_es;
svector<std::pair<expr*,expr*>> m_eqs;
u_map<expr*> m_roots;
obj_map<expr, unsigned> m_expr2var;
ptr_vector<expr> m_var2expr;
expr_mark m_mark;
br_status mk_or(unsigned num_args, expr * const * args, expr_ref & result);
bool is_and(expr* e, expr_ref_vector* args);
bool is_var(expr* e) { return m_expr2var.contains(e); }
expr* mk_expr(unsigned v) { return m_var2expr[v]; }
unsigned mk_var(expr* e);
void reset(basic_union_find& uf);
public:
hoist_rewriter(ast_manager & m, params_ref const & p = params_ref());
ast_manager& m() const { return m_manager; }
family_id get_fid() const { return m().get_basic_family_id(); }
bool is_eq(expr * t) const { return m().is_eq(t); }
void updt_params(params_ref const & p) {}
static void get_param_descrs(param_descrs & r) {}
br_status mk_app_core(func_decl * f, unsigned num_args, expr * const * args, expr_ref & result);
};
struct hoist_rewriter_cfg : public default_rewriter_cfg {
hoist_rewriter m_r;
bool rewrite_patterns() const { return false; }
br_status reduce_app(func_decl * f, unsigned num, expr * const * args, expr_ref & result, proof_ref & result_pr) {
result_pr = nullptr;
if (f->get_family_id() != m_r.get_fid())
return BR_FAILED;
return m_r.mk_app_core(f, num, args, result);
}
hoist_rewriter_cfg(ast_manager & m, params_ref const & p):m_r(m, p) {}
};
class hoist_rewriter_star : public rewriter_tpl<hoist_rewriter_cfg> {
hoist_rewriter_cfg m_cfg;
public:
hoist_rewriter_star(ast_manager & m, params_ref const & p = params_ref()):
rewriter_tpl<hoist_rewriter_cfg>(m, false, m_cfg),
m_cfg(m, p) {}
};
#endif

View file

@ -323,7 +323,7 @@ br_status pb_rewriter::mk_app_core(func_decl * f, unsigned num_args, expr * cons
break;
}
}
TRACE("pb",
TRACE("pb_verbose",
expr_ref tmp(m);
tmp = m.mk_app(f, num_args, args);
tout << tmp << "\n";

View file

@ -42,7 +42,7 @@ void rewriter_core::del_cache_stack() {
}
}
void rewriter_core::cache_result(expr * k, expr * v) {
void rewriter_core::cache_shifted_result(expr * k, unsigned offset, expr * v) {
#if 0
// trace for tracking cache usage
verbose_stream() << "1 " << k->get_id() << std::endl;
@ -53,7 +53,7 @@ void rewriter_core::cache_result(expr * k, expr * v) {
SASSERT(m().get_sort(k) == m().get_sort(v));
m_cache->insert(k, v);
m_cache->insert(k, offset, v);
#if 0
static unsigned num_cached = 0;
num_cached ++;

View file

@ -90,8 +90,10 @@ protected:
void init_cache_stack();
void del_cache_stack();
void reset_cache();
void cache_result(expr * k, expr * v);
void cache_result(expr * k, expr * v) { cache_shifted_result(k, 0, v); }
void cache_shifted_result(expr * k, unsigned offset, expr * v);
expr * get_cached(expr * k) const { return m_cache->find(k); }
expr * get_cached(expr* k, unsigned offset) const { return m_cache->find(k, offset); }
void cache_result(expr * k, expr * v, proof * pr);
proof * get_cached_pr(expr * k) const { return static_cast<proof*>(m_cache_pr->find(k)); }

View file

@ -38,9 +38,10 @@ void rewriter_tpl<Config>::process_var(var * v) {
if (!ProofGen) {
// bindings are only used when Proof Generation is not enabled.
unsigned idx = v->get_idx();
if (idx < m_bindings.size()) {
unsigned index = m_bindings.size() - idx - 1;
var * r = (var*)(m_bindings[index]);
expr * r = m_bindings[index];
if (r != nullptr) {
CTRACE("rewriter", v->get_sort() != m().get_sort(r),
tout << expr_ref(v, m()) << ":" << sort_ref(v->get_sort(), m()) << " != " << expr_ref(r, m()) << ":" << sort_ref(m().get_sort(r), m());
@ -50,11 +51,18 @@ void rewriter_tpl<Config>::process_var(var * v) {
if (!is_ground(r) && m_shifts[index] != m_bindings.size()) {
unsigned shift_amount = m_bindings.size() - m_shifts[index];
expr* c = get_cached(r, shift_amount);
if (c) {
result_stack().push_back(c);
set_new_child_flag(v);
return;
}
expr_ref tmp(m());
m_shifter(r, shift_amount, tmp);
result_stack().push_back(tmp);
TRACE("rewriter", tout << "shift: " << shift_amount << " idx: " << idx << " --> " << tmp << "\n";
display_bindings(tout););
cache_shifted_result(r, shift_amount, tmp);
}
else {
result_stack().push_back(r);
@ -380,7 +388,6 @@ void rewriter_tpl<Config>::process_app(app * t, frame & fr) {
TRACE("get_macro", display_bindings(tout););
begin_scope();
m_num_qvars += num_args;
//m_num_qvars = 0;
m_root = def;
push_frame(def, false, RW_UNBOUNDED_DEPTH);
return;
@ -480,7 +487,7 @@ void rewriter_tpl<Config>::process_quantifier(quantifier * q, frame & fr) {
m_root = q->get_expr();
unsigned sz = m_bindings.size();
for (unsigned i = 0; i < num_decls; i++) {
m_bindings.push_back(0);
m_bindings.push_back(nullptr);
m_shifts.push_back(sz);
}
}
@ -514,7 +521,12 @@ void rewriter_tpl<Config>::process_quantifier(quantifier * q, frame & fr) {
}
if (ProofGen) {
quantifier_ref new_q(m().update_quantifier(q, num_pats, new_pats.c_ptr(), num_no_pats, new_no_pats.c_ptr(), new_body), m());
m_pr = q == new_q ? nullptr : m().mk_quant_intro(q, new_q, result_pr_stack().get(fr.m_spos));
m_pr = nullptr;
if (q != new_q) {
m_pr = result_pr_stack().get(fr.m_spos);
m_pr = m().mk_bind_proof(q, m_pr);
m_pr = m().mk_quant_intro(q, new_q, m_pr);
}
m_r = new_q;
proof_ref pr2(m());
if (m_cfg.reduce_quantifier(new_q, new_body, new_pats.c_ptr(), new_no_pats.c_ptr(), m_r, pr2)) {

View file

@ -33,30 +33,32 @@ Notes:
expr_ref sym_expr::accept(expr* e) {
ast_manager& m = m_t.get_manager();
expr_ref result(m);
var_subst subst(m);
seq_util u(m);
unsigned r1, r2, r3;
switch (m_ty) {
case t_pred: {
var_subst subst(m);
case t_pred:
result = subst(m_t, 1, &e);
break;
case t_not:
result = m_expr->accept(e);
result = m.mk_not(result);
break;
}
case t_char:
SASSERT(m.get_sort(e) == m.get_sort(m_t));
SASSERT(m.get_sort(e) == m_sort);
result = m.mk_eq(e, m_t);
break;
case t_range: {
bv_util bv(m);
rational r1, r2, r3;
unsigned sz;
if (bv.is_numeral(m_t, r1, sz) && bv.is_numeral(e, r2, sz) && bv.is_numeral(m_s, r3, sz)) {
case t_range:
if (u.is_const_char(m_t, r1) && u.is_const_char(e, r2) && u.is_const_char(m_s, r3)) {
result = m.mk_bool_val((r1 <= r2) && (r2 <= r3));
}
else {
result = m.mk_and(bv.mk_ule(m_t, e), bv.mk_ule(e, m_s));
result = m.mk_and(u.mk_le(m_t, e), u.mk_le(e, m_s));
}
break;
}
}
return result;
}
@ -65,6 +67,7 @@ std::ostream& sym_expr::display(std::ostream& out) const {
case t_char: return out << m_t;
case t_range: return out << m_t << ":" << m_s;
case t_pred: return out << m_t;
case t_not: return m_expr->display(out << "not ");
}
return out << "expression type not recognized";
}
@ -80,10 +83,11 @@ struct display_expr1 {
class sym_expr_boolean_algebra : public boolean_algebra<sym_expr*> {
ast_manager& m;
expr_solver& m_solver;
expr_ref m_var;
typedef sym_expr* T;
public:
sym_expr_boolean_algebra(ast_manager& m, expr_solver& s):
m(m), m_solver(s) {}
m(m), m_solver(s), m_var(m) {}
T mk_false() override {
expr_ref fml(m.mk_false(), m);
@ -94,6 +98,7 @@ public:
return sym_expr::mk_pred(fml, m.mk_bool_sort());
}
T mk_and(T x, T y) override {
seq_util u(m);
if (x->is_char() && y->is_char()) {
if (x->get_char() == y->get_char()) {
return x;
@ -103,6 +108,21 @@ public:
return sym_expr::mk_pred(fml, x->get_sort());
}
}
unsigned lo1, hi1, lo2, hi2;
if (x->is_range() && y->is_range() &&
u.is_const_char(x->get_lo(), lo1) && u.is_const_char(x->get_hi(), hi1) &&
u.is_const_char(y->get_lo(), lo2) && u.is_const_char(y->get_hi(), hi2)) {
lo1 = std::max(lo1, lo2);
hi1 = std::min(hi1, hi2);
if (lo1 > hi1) {
expr_ref fml(m.mk_false(), m);
return sym_expr::mk_pred(fml, x->get_sort());
}
expr_ref _start(u.mk_char(lo1), m);
expr_ref _stop(u.mk_char(hi1), m);
return sym_expr::mk_range(_start, _stop);
}
sort* s = x->get_sort();
if (m.is_bool(s)) s = y->get_sort();
var_ref v(m.mk_var(0, s), m);
@ -111,13 +131,29 @@ public:
if (m.is_true(fml1)) {
return y;
}
if (m.is_true(fml2)) return x;
if (fml1 == fml2) return x;
if (m.is_true(fml2)) {
return x;
}
if (fml1 == fml2) {
return x;
}
if (is_complement(fml1, fml2)) {
expr_ref ff(m.mk_false(), m);
return sym_expr::mk_pred(ff, x->get_sort());
}
bool_rewriter br(m);
expr_ref fml(m);
br.mk_and(fml1, fml2, fml);
return sym_expr::mk_pred(fml, x->get_sort());
}
bool is_complement(expr* f1, expr* f2) {
expr* f = nullptr;
return
(m.is_not(f1, f) && f == f2) ||
(m.is_not(f2, f) && f == f1);
}
T mk_or(T x, T y) override {
if (x->is_char() && y->is_char() &&
x->get_char() == y->get_char()) {
@ -148,6 +184,7 @@ public:
}
}
}
T mk_or(unsigned sz, T const* ts) override {
switch (sz) {
case 0: return mk_false();
@ -161,15 +198,24 @@ public:
}
}
}
lbool is_sat(T x) override {
unsigned lo, hi;
seq_util u(m);
if (x->is_char()) {
return l_true;
}
if (x->is_range()) {
// TBD check lower is below upper.
if (x->is_range() && u.is_const_char(x->get_lo(), lo) && u.is_const_char(x->get_hi(), hi)) {
return (lo <= hi) ? l_true : l_false;
}
expr_ref v(m.mk_fresh_const("x", x->get_sort()), m);
expr_ref fml = x->accept(v);
if (x->is_not() && x->get_arg()->is_range() && u.is_const_char(x->get_arg()->get_lo(), lo) && 0 < lo) {
return l_true;
}
if (!m_var || m.get_sort(m_var) != x->get_sort()) {
m_var = m.mk_fresh_const("x", x->get_sort());
}
expr_ref fml = x->accept(m_var);
if (m.is_true(fml)) {
return l_true;
}
@ -178,19 +224,14 @@ public:
}
return m_solver.check_sat(fml);
}
T mk_not(T x) override {
var_ref v(m.mk_var(0, x->get_sort()), m);
expr_ref fml(m.mk_not(x->accept(v)), m);
return sym_expr::mk_pred(fml, x->get_sort());
return sym_expr::mk_not(m, x);
}
/*virtual vector<std::pair<vector<bool>, T>> generate_min_terms(vector<T> constraints){
return 0;
}*/
};
re2automaton::re2automaton(ast_manager& m): m(m), u(m), bv(m), m_ba(nullptr), m_sa(nullptr) {}
re2automaton::re2automaton(ast_manager& m): m(m), u(m), m_ba(nullptr), m_sa(nullptr) {}
re2automaton::~re2automaton() {}
@ -248,9 +289,8 @@ eautomaton* re2automaton::re2aut(expr* e) {
s1.length() == 1 && s2.length() == 1) {
unsigned start = s1[0];
unsigned stop = s2[0];
unsigned nb = s1.num_bits();
expr_ref _start(bv.mk_numeral(start, nb), m);
expr_ref _stop(bv.mk_numeral(stop, nb), m);
expr_ref _start(u.mk_char(start), m);
expr_ref _stop(u.mk_char(stop), m);
TRACE("seq", tout << "Range: " << start << " " << stop << "\n";);
a = alloc(eautomaton, sm, sym_expr::mk_range(_start, _stop));
return a.detach();
@ -309,6 +349,9 @@ eautomaton* re2automaton::re2aut(expr* e) {
else if (u.re.is_intersection(e, e1, e2) && m_sa && (a = re2aut(e1)) && (b = re2aut(e2))) {
return m_sa->mk_product(*a, *b);
}
else {
TRACE("seq", tout << "not handled " << mk_pp(e, m) << "\n";);
}
return nullptr;
}
@ -343,9 +386,9 @@ eautomaton* re2automaton::seq2aut(expr* e) {
br_status seq_rewriter::mk_app_core(func_decl * f, unsigned num_args, expr * const * args, expr_ref & result) {
SASSERT(f->get_family_id() == get_fid());
br_status st = BR_FAILED;
switch(f->get_decl_kind()) {
case OP_SEQ_UNIT:
SASSERT(num_args == 1);
return mk_seq_unit(args[0], result);
@ -356,16 +399,19 @@ br_status seq_rewriter::mk_app_core(func_decl * f, unsigned num_args, expr * con
return mk_re_plus(args[0], result);
case OP_RE_STAR:
SASSERT(num_args == 1);
return mk_re_star(args[0], result);
st = mk_re_star(args[0], result);
break;
case OP_RE_OPTION:
SASSERT(num_args == 1);
return mk_re_opt(args[0], result);
case OP_RE_CONCAT:
if (num_args == 1) {
result = args[0]; return BR_DONE;
result = args[0];
return BR_DONE;
}
SASSERT(num_args == 2);
return mk_re_concat(args[0], args[1], result);
st = mk_re_concat(args[0], args[1], result);
break;
case OP_RE_UNION:
if (num_args == 1) {
result = args[0]; return BR_DONE;
@ -405,13 +451,19 @@ br_status seq_rewriter::mk_app_core(func_decl * f, unsigned num_args, expr * con
return mk_seq_length(args[0], result);
case OP_SEQ_EXTRACT:
SASSERT(num_args == 3);
return mk_seq_extract(args[0], args[1], args[2], result);
st = mk_seq_extract(args[0], args[1], args[2], result);
break;
case OP_SEQ_CONTAINS:
SASSERT(num_args == 2);
return mk_seq_contains(args[0], args[1], result);
case OP_SEQ_AT:
SASSERT(num_args == 2);
return mk_seq_at(args[0], args[1], result);
#if 0
case OP_SEQ_NTH:
SASSERT(num_args == 2);
return mk_seq_nth(args[0], args[1], result);
#endif
case OP_SEQ_PREFIX:
SASSERT(num_args == 2);
return mk_seq_prefix(args[0], args[1], result);
@ -456,21 +508,20 @@ br_status seq_rewriter::mk_app_core(func_decl * f, unsigned num_args, expr * con
case _OP_STRING_STRIDOF:
UNREACHABLE();
}
return BR_FAILED;
CTRACE("seq", st != BR_FAILED, tout << result << "\n";);
return st;
}
/*
* (seq.unit (_ BitVector 8)) ==> String constant
*/
br_status seq_rewriter::mk_seq_unit(expr* e, expr_ref& result) {
bv_util bvu(m());
rational n_val;
unsigned int n_size;
unsigned ch;
// specifically we want (_ BitVector 8)
if (bvu.is_bv(e) && bvu.is_numeral(e, n_val, n_size) && n_size == 8) {
if (m_util.is_const_char(e, ch)) {
// convert to string constant
zstring str(n_val.get_unsigned());
TRACE("seq_verbose", tout << "rewrite seq.unit of 8-bit value " << n_val.to_string() << " to string constant \"" << str<< "\"" << std::endl;);
zstring str(ch);
TRACE("seq_verbose", tout << "rewrite seq.unit of 8-bit value " << ch << " to string constant \"" << str<< "\"" << std::endl;);
result = m_util.str.mk_string(str);
return BR_DONE;
}
@ -566,6 +617,7 @@ br_status seq_rewriter::mk_seq_extract(expr* a, expr* b, expr* c, expr_ref& resu
bool constantPos = m_autil.is_numeral(b, pos);
bool constantLen = m_autil.is_numeral(c, len);
// case 1: pos<0 or len<=0
// rewrite to ""
if ( (constantPos && pos.is_neg()) || (constantLen && !len.is_pos()) ) {
@ -574,7 +626,7 @@ br_status seq_rewriter::mk_seq_extract(expr* a, expr* b, expr* c, expr_ref& resu
}
// case 1.1: pos >= length(base)
// rewrite to ""
if (constantBase && constantPos && pos >= rational(s.length())) {
if (constantPos && constantBase && pos >= rational(s.length())) {
result = m_util.str.mk_empty(m().get_sort(a));
return BR_DONE;
}
@ -582,52 +634,73 @@ br_status seq_rewriter::mk_seq_extract(expr* a, expr* b, expr* c, expr_ref& resu
constantPos &= pos.is_unsigned();
constantLen &= len.is_unsigned();
if (constantBase && constantPos && constantLen) {
if (pos.get_unsigned() + len.get_unsigned() >= s.length()) {
// case 2: pos+len goes past the end of the string
unsigned _len = s.length() - pos.get_unsigned() + 1;
result = m_util.str.mk_string(s.extract(pos.get_unsigned(), _len));
} else {
// case 3: pos+len still within string
result = m_util.str.mk_string(s.extract(pos.get_unsigned(), len.get_unsigned()));
}
return BR_DONE;
}
if (constantPos && constantLen) {
if (constantPos && constantLen && constantBase) {
unsigned _pos = pos.get_unsigned();
unsigned _len = len.get_unsigned();
SASSERT(_len > 0);
expr_ref_vector as(m()), bs(m());
m_util.str.get_concat(a, as);
if (as.empty()) {
result = a;
return BR_DONE;
}
for (unsigned i = 0; i < as.size() && _len > 0; ++i) {
if (m_util.str.is_unit(as[i].get())) {
if (_pos == 0) {
bs.push_back(as[i].get());
--_len;
}
else {
--_pos;
}
}
else {
return BR_FAILED;
}
}
if (bs.empty()) {
result = m_util.str.mk_empty(m().get_sort(a));
}
else {
result = m_util.str.mk_concat(bs);
if (_pos + _len >= s.length()) {
// case 2: pos+len goes past the end of the string
unsigned _len = s.length() - _pos + 1;
result = m_util.str.mk_string(s.extract(_pos, _len));
} else {
// case 3: pos+len still within string
result = m_util.str.mk_string(s.extract(_pos, _len));
}
return BR_DONE;
}
return BR_FAILED;
expr_ref_vector as(m()), bs(m());
m_util.str.get_concat_units(a, as);
if (as.empty()) {
result = m_util.str.mk_empty(m().get_sort(a));
return BR_DONE;
}
if (!constantPos) {
return BR_FAILED;
}
unsigned _pos = pos.get_unsigned();
// (extract s 0 (len s)) = s
expr* a2 = nullptr;
if (_pos == 0 && m_util.str.is_length(c, a2) && a == a2) {
result = a;
return BR_DONE;
}
unsigned offset = 0;
for (; offset < as.size() && m_util.str.is_unit(as.get(offset)) && offset < _pos; ++offset) {};
if (offset == 0 && _pos > 0) {
return BR_FAILED;
}
if (_pos == 0 && !constantLen) {
return BR_FAILED;
}
// (extract (++ (unit x) (unit y)) 3 c) = empty
if (offset == as.size()) {
result = m_util.str.mk_empty(m().get_sort(a));
return BR_DONE;
}
SASSERT(offset != 0 || _pos == 0);
if (constantLen && _pos == offset) {
unsigned _len = len.get_unsigned();
// (extract (++ (unit a) (unit b) (unit c) x) 1 2) = (++ (unit b) (unit c))
unsigned i = offset;
for (; i < as.size() && m_util.str.is_unit(as.get(i)) && i - offset < _len; ++i);
if (i - offset == _len) {
result = m_util.str.mk_concat(_len, as.c_ptr() + offset);
return BR_DONE;
}
}
if (offset == 0) {
return BR_FAILED;
}
expr_ref pos1(m());
pos1 = m_autil.mk_sub(b, m_autil.mk_int(offset));
result = m_util.str.mk_concat(as.size() - offset, as.c_ptr() + offset);
result = m_util.str.mk_substr(result, pos1, c);
return BR_REWRITE3;
}
bool seq_rewriter::cannot_contain_suffix(expr* a, expr* b) {
@ -809,6 +882,32 @@ br_status seq_rewriter::mk_seq_at(expr* a, expr* b, expr_ref& result) {
return BR_DONE;
}
br_status seq_rewriter::mk_seq_nth(expr* a, expr* b, expr_ref& result) {
zstring c;
rational r;
if (!m_autil.is_numeral(b, r) || !r.is_unsigned()) {
return BR_FAILED;
}
unsigned len = r.get_unsigned();
expr_ref_vector as(m());
m_util.str.get_concat_units(a, as);
for (unsigned i = 0; i < as.size(); ++i) {
expr* a = as.get(i), *u = nullptr;
if (m_util.str.is_unit(a, u)) {
if (len == i) {
result = u;
return BR_DONE;
}
}
else {
return BR_FAILED;
}
}
return BR_FAILED;
}
br_status seq_rewriter::mk_seq_index(expr* a, expr* b, expr* c, expr_ref& result) {
zstring s1, s2;
rational r;
@ -1238,6 +1337,7 @@ br_status seq_rewriter::mk_str_in_regexp(expr* a, expr* b, expr_ref& result) {
scoped_ptr<eautomaton> aut;
expr_ref_vector seq(m());
if (!(aut = m_re2aut(b))) {
TRACE("seq", tout << "not translated to automaton " << mk_pp(b, m()) << "\n";);
return BR_FAILED;
}
@ -1254,6 +1354,7 @@ br_status seq_rewriter::mk_str_in_regexp(expr* a, expr* b, expr_ref& result) {
}
if (!is_sequence(a, seq)) {
TRACE("seq", tout << "not a sequence " << mk_pp(a, m()) << "\n";);
return BR_FAILED;
}
@ -1305,17 +1406,16 @@ br_status seq_rewriter::mk_str_in_regexp(expr* a, expr* b, expr_ref& result) {
}
}
u_map<expr*> const& frontier = maps[select_map];
u_map<expr*>::iterator it = frontier.begin(), end = frontier.end();
expr_ref_vector ors(m());
for (; it != end; ++it) {
for (auto const& kv : frontier) {
unsigned_vector states;
bool has_final = false;
aut->get_epsilon_closure(it->m_key, states);
aut->get_epsilon_closure(kv.m_key, states);
for (unsigned i = 0; i < states.size() && !has_final; ++i) {
has_final = aut->is_final_state(states[i]);
}
if (has_final) {
ors.push_back(it->m_value);
ors.push_back(kv.m_value);
}
}
result = mk_or(ors);
@ -1434,6 +1534,14 @@ br_status seq_rewriter::mk_re_inter(expr* a, expr* b, expr_ref& result) {
result = a;
return BR_DONE;
}
expr* ac = nullptr, *bc = nullptr;
if ((m_util.re.is_complement(a, ac) && ac == b) ||
(m_util.re.is_complement(b, bc) && bc == a)) {
sort* seq_sort = nullptr;
VERIFY(m_util.is_re(a, seq_sort));
result = m_util.re.mk_empty(seq_sort);
return BR_DONE;
}
return BR_FAILED;
}
@ -1977,15 +2085,13 @@ bool seq_rewriter::min_length(unsigned n, expr* const* es, unsigned& len) {
bool seq_rewriter::is_string(unsigned n, expr* const* es, zstring& s) const {
zstring s1;
expr* e;
bv_util bv(m());
rational val;
unsigned sz;
unsigned ch;
for (unsigned i = 0; i < n; ++i) {
if (m_util.str.is_string(es[i], s1)) {
s = s + s1;
}
else if (m_util.str.is_unit(es[i], e) && bv.is_numeral(e, val, sz)) {
s = s + zstring(val.get_unsigned());
else if (m_util.str.is_unit(es[i], e) && m_util.is_const_char(e, ch)) {
s = s + zstring(ch);
}
else {
return false;

View file

@ -31,31 +31,38 @@ class sym_expr {
enum ty {
t_char,
t_pred,
t_not,
t_range
};
ty m_ty;
sort* m_sort;
expr_ref m_t;
expr_ref m_s;
unsigned m_ref;
sym_expr(ty ty, expr_ref& t, expr_ref& s, sort* srt) : m_ty(ty), m_sort(srt), m_t(t), m_s(s), m_ref(0) {}
ty m_ty;
sort* m_sort;
sym_expr* m_expr;
expr_ref m_t;
expr_ref m_s;
unsigned m_ref;
sym_expr(ty ty, expr_ref& t, expr_ref& s, sort* srt, sym_expr* e) :
m_ty(ty), m_sort(srt), m_expr(e), m_t(t), m_s(s), m_ref(0) {}
public:
~sym_expr() { if (m_expr) m_expr->dec_ref(); }
expr_ref accept(expr* e);
static sym_expr* mk_char(expr_ref& t) { return alloc(sym_expr, t_char, t, t, t.get_manager().get_sort(t)); }
static sym_expr* mk_char(expr_ref& t) { return alloc(sym_expr, t_char, t, t, t.get_manager().get_sort(t), nullptr); }
static sym_expr* mk_char(ast_manager& m, expr* t) { expr_ref tr(t, m); return mk_char(tr); }
static sym_expr* mk_pred(expr_ref& t, sort* s) { return alloc(sym_expr, t_pred, t, t, s); }
static sym_expr* mk_range(expr_ref& lo, expr_ref& hi) { return alloc(sym_expr, t_range, lo, hi, lo.get_manager().get_sort(hi)); }
static sym_expr* mk_pred(expr_ref& t, sort* s) { return alloc(sym_expr, t_pred, t, t, s, nullptr); }
static sym_expr* mk_range(expr_ref& lo, expr_ref& hi) { return alloc(sym_expr, t_range, lo, hi, lo.get_manager().get_sort(hi), nullptr); }
static sym_expr* mk_not(ast_manager& m, sym_expr* e) { expr_ref f(m); e->inc_ref(); return alloc(sym_expr, t_not, f, f, e->get_sort(), e); }
void inc_ref() { ++m_ref; }
void dec_ref() { --m_ref; if (m_ref == 0) dealloc(this); }
std::ostream& display(std::ostream& out) const;
bool is_char() const { return m_ty == t_char; }
bool is_pred() const { return !is_char(); }
bool is_range() const { return m_ty == t_range; }
bool is_not() const { return m_ty == t_not; }
sort* get_sort() const { return m_sort; }
expr* get_char() const { SASSERT(is_char()); return m_t; }
expr* get_pred() const { SASSERT(is_pred()); return m_t; }
expr* get_lo() const { SASSERT(is_range()); return m_t; }
expr* get_hi() const { SASSERT(is_range()); return m_s; }
sym_expr* get_arg() const { SASSERT(is_not()); return m_expr; }
};
class sym_expr_manager {
@ -77,7 +84,6 @@ class re2automaton {
ast_manager& m;
sym_expr_manager sm;
seq_util u;
bv_util bv;
scoped_ptr<expr_solver> m_solver;
scoped_ptr<boolean_algebra_t> m_ba;
scoped_ptr<symbolic_automata_t> m_sa;
@ -108,6 +114,7 @@ class seq_rewriter {
br_status mk_seq_extract(expr* a, expr* b, expr* c, expr_ref& result);
br_status mk_seq_contains(expr* a, expr* b, expr_ref& result);
br_status mk_seq_at(expr* a, expr* b, expr_ref& result);
br_status mk_seq_nth(expr* a, expr* b, expr_ref& result);
br_status mk_seq_index(expr* a, expr* b, expr* c, expr_ref& result);
br_status mk_seq_replace(expr* a, expr* b, expr* c, expr_ref& result);
br_status mk_seq_prefix(expr* a, expr* b, expr_ref& result);

View file

@ -135,17 +135,14 @@ expr_ref unused_vars_eliminator::operator()(quantifier* q) {
return result;
}
expr_ref tmp(m);
expr_ref_buffer new_patterns(m);
expr_ref_buffer new_no_patterns(m);
for (unsigned i = 0; i < num_patterns; i++) {
tmp = m_subst(q->get_pattern(i), var_mapping.size(), var_mapping.c_ptr());
new_patterns.push_back(tmp);
new_patterns.push_back(m_subst(q->get_pattern(i), var_mapping.size(), var_mapping.c_ptr()));
}
for (unsigned i = 0; i < num_no_patterns; i++) {
tmp = m_subst(q->get_no_pattern(i), var_mapping.size(), var_mapping.c_ptr());
new_no_patterns.push_back(tmp);
new_no_patterns.push_back(m_subst(q->get_no_pattern(i), var_mapping.size(), var_mapping.c_ptr()));
}
result = m.mk_quantifier(q->get_kind(),

View file

@ -20,6 +20,7 @@ Revision History:
#include "ast/arith_decl_plugin.h"
#include "ast/array_decl_plugin.h"
#include "ast/ast_pp.h"
#include "ast/bv_decl_plugin.h"
#include <sstream>
static bool is_hex_digit(char ch, unsigned& d) {
@ -68,14 +69,14 @@ static bool is_escape_char(char const *& s, unsigned& result) {
}
/* 2 octal digits */
if (is_octal_digit(*(s + 1), d1) && is_octal_digit(*(s + 2), d2) &&
!is_octal_digit(*(s + 3), d3)) {
!is_octal_digit(*(s + 3), d3)) {
result = d1 * 8 + d2;
s += 3;
return true;
}
/* 3 octal digits */
if (is_octal_digit(*(s + 1), d1) && is_octal_digit(*(s + 2), d2) &&
is_octal_digit(*(s + 3), d3)) {
is_octal_digit(*(s + 3), d3)) {
result = d1*64 + d2*8 + d3;
s += 4;
return true;
@ -295,13 +296,10 @@ bool zstring::operator==(const zstring& other) const {
return false;
}
for (unsigned i = 0; i < length(); ++i) {
unsigned Xi = m_buffer[i];
unsigned Yi = other[i];
if (Xi != Yi) {
if (m_buffer[i] != other[i]) {
return false;
}
}
return true;
}
@ -324,19 +322,14 @@ bool operator<(const zstring& lhs, const zstring& rhs) {
unsigned Ri = rhs[i];
if (Li < Ri) {
return true;
} else if (Li > Ri) {
}
else if (Li > Ri) {
return false;
} else {
continue;
}
}
}
// at this point, all compared characters are equal,
// so decide based on the relative lengths
if (lhs.length() < rhs.length()) {
return true;
} else {
return false;
}
return lhs.length() < rhs.length();
}
@ -377,8 +370,8 @@ bool seq_decl_plugin::match(ptr_vector<sort>& binding, sort* s, sort* sP) {
if (s->get_family_id() == sP->get_family_id() &&
s->get_decl_kind() == sP->get_decl_kind() &&
s->get_num_parameters() == sP->get_num_parameters()) {
for (unsigned i = 0, sz = s->get_num_parameters(); i < sz; ++i) {
parameter const& p = s->get_parameter(i);
for (unsigned i = 0, sz = s->get_num_parameters(); i < sz; ++i) {
parameter const& p = s->get_parameter(i);
if (p.is_ast() && is_sort(p.get_ast())) {
parameter const& p2 = sP->get_parameter(i);
if (!match(binding, to_sort(p.get_ast()), to_sort(p2.get_ast()))) return false;
@ -435,7 +428,7 @@ void seq_decl_plugin::match_right_assoc(psig& sig, unsigned dsz, sort *const* do
}
void seq_decl_plugin::match(psig& sig, unsigned dsz, sort *const* dom, sort* range, sort_ref& range_out) {
ptr_vector<sort> binding;
m_binding.reset();
ast_manager& m = *m_manager;
if (sig.m_dom.size() != dsz) {
std::ostringstream strm;
@ -445,10 +438,10 @@ void seq_decl_plugin::match(psig& sig, unsigned dsz, sort *const* dom, sort* ran
}
bool is_match = true;
for (unsigned i = 0; is_match && i < dsz; ++i) {
is_match = match(binding, dom[i], sig.m_dom[i].get());
is_match = match(m_binding, dom[i], sig.m_dom[i].get());
}
if (range && is_match) {
is_match = match(binding, range, sig.m_range);
is_match = match(m_binding, range, sig.m_range);
}
if (!is_match) {
std::ostringstream strm;
@ -474,7 +467,7 @@ void seq_decl_plugin::match(psig& sig, unsigned dsz, sort *const* dom, sort* ran
strm << "is ambiguous. Function takes no arguments and sort of range has not been constrained";
m.raise_exception(strm.str().c_str());
}
range_out = apply_binding(binding, sig.m_range);
range_out = apply_binding(m_binding, sig.m_range);
SASSERT(range_out);
}
@ -555,7 +548,7 @@ void seq_decl_plugin::init() {
m_sigs[OP_RE_OF_PRED] = alloc(psig, m, "re.of.pred", 1, 1, &predA, reA);
m_sigs[OP_SEQ_TO_RE] = alloc(psig, m, "seq.to.re", 1, 1, &seqA, reA);
m_sigs[OP_SEQ_IN_RE] = alloc(psig, m, "seq.in.re", 1, 2, seqAreA, boolT);
m_sigs[OP_STRING_CONST] = 0;
m_sigs[OP_STRING_CONST] = nullptr;
m_sigs[_OP_STRING_STRIDOF] = alloc(psig, m, "str.indexof", 0, 3, str2TintT, intT);
m_sigs[_OP_STRING_STRREPL] = alloc(psig, m, "str.replace", 0, 3, str3T, strT);
m_sigs[OP_STRING_ITOS] = alloc(psig, m, "int.to.str", 0, 1, &intT, strT);
@ -967,6 +960,24 @@ app* seq_util::str::mk_char(char ch) const {
return mk_char(s, 0);
}
bool seq_util::is_const_char(expr* e, unsigned& c) const {
bv_util bv(m);
rational r;
unsigned sz;
return bv.is_numeral(e, r, sz) && sz == 8 && r.is_unsigned() && (c = r.get_unsigned(), true);
}
app* seq_util::mk_char(unsigned ch) const {
bv_util bv(m);
return bv.mk_numeral(rational(ch), 8);
}
app* seq_util::mk_le(expr* ch1, expr* ch2) const {
bv_util bv(m);
return bv.mk_ule(ch1, ch2);
}
bool seq_util::str::is_string(expr const* n, zstring& s) const {
if (is_string(n)) {
s = zstring(to_app(n)->get_decl()->get_parameter(0).get_symbol().bare_str());
@ -1044,7 +1055,6 @@ app* seq_util::re::mk_empty(sort* s) {
return m.mk_app(m_fid, OP_RE_EMPTY_SET, 0, nullptr, 0, nullptr, s);
}
bool seq_util::re::is_loop(expr const* n, expr*& body, unsigned& lo, unsigned& hi) {
if (is_loop(n)) {
app const* a = to_app(n);

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