3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-24 09:35:32 +00:00

Merge branch 'fpa-api' of https://git01.codeplex.com/z3 into unstable

Signed-off-by: Christoph M. Wintersteiger <cwinter@microsoft.com>

Conflicts:
	src/tactic/portfolio/default_tactic.cpp
This commit is contained in:
Christoph M. Wintersteiger 2015-01-21 14:25:31 +00:00
commit d56d63e3e8
110 changed files with 11348 additions and 4084 deletions

View file

@ -27,7 +27,7 @@ Notes:
struct aig;
class aig_lit {
friend class aig_ref;
friend class aig_ref;
aig * m_ref;
public:
aig_lit(aig * n = 0):m_ref(n) {}
@ -1508,10 +1508,10 @@ public:
template<typename S>
aig_lit mk_aig(S const & s) {
aig_lit r;
r = m_true;
inc_ref(r);
r = m_true;
inc_ref(r);
try {
expr2aig proc(*this);
expr2aig proc(*this);
unsigned sz = s.size();
for (unsigned i = 0; i < sz; i++) {
SASSERT(ref_count(r) >= 1);
@ -1528,10 +1528,10 @@ public:
}
SASSERT(ref_count(r) >= 1);
}
catch (aig_exception ex) {
dec_ref(r);
throw ex;
}
catch (aig_exception ex) {
dec_ref(r);
throw ex;
}
dec_ref_result(r);
return r;
}

View file

@ -85,7 +85,7 @@ model_converter * fpa2bv_model_converter::translate(ast_translation & translator
}
void fpa2bv_model_converter::convert(model * bv_mdl, model * float_mdl) {
float_util fu(m);
fpa_util fu(m);
bv_util bu(m);
mpf fp_val;
unsynch_mpz_manager & mpzm = fu.fm().mpz_manager();
@ -112,16 +112,16 @@ void fpa2bv_model_converter::convert(model * bv_mdl, model * float_mdl) {
unsigned sbits = fu.get_sbits(var->get_range());
expr_ref sgn(m), sig(m), exp(m);
bv_mdl->eval(a->get_arg(0), sgn, true);
bv_mdl->eval(a->get_arg(1), sig, true);
bv_mdl->eval(a->get_arg(2), exp, true);
bv_mdl->eval(a->get_arg(0), sgn, true);
bv_mdl->eval(a->get_arg(1), exp, true);
bv_mdl->eval(a->get_arg(2), sig, true);
SASSERT(a->is_app_of(fu.get_family_id(), OP_TO_FLOAT));
SASSERT(a->is_app_of(fu.get_family_id(), OP_FPA_FP));
#ifdef Z3DEBUG
SASSERT(to_app(a->get_arg(0))->get_decl()->get_arity() == 0);
SASSERT(to_app(a->get_arg(1))->get_decl()->get_arity() == 0);
SASSERT(to_app(a->get_arg(1))->get_decl()->get_arity() == 0);
SASSERT(to_app(a->get_arg(2))->get_decl()->get_arity() == 0);
seen.insert(to_app(a->get_arg(0))->get_decl());
seen.insert(to_app(a->get_arg(1))->get_decl());
seen.insert(to_app(a->get_arg(2))->get_decl());
@ -134,9 +134,9 @@ void fpa2bv_model_converter::convert(model * bv_mdl, model * float_mdl) {
if (!sgn && !sig && !exp)
continue;
unsigned sgn_sz = bu.get_bv_size(m.get_sort(a->get_arg(0)));
unsigned sig_sz = bu.get_bv_size(m.get_sort(a->get_arg(1))) - 1;
unsigned exp_sz = bu.get_bv_size(m.get_sort(a->get_arg(2)));
unsigned sgn_sz = bu.get_bv_size(m.get_sort(a->get_arg(0)));
unsigned exp_sz = bu.get_bv_size(m.get_sort(a->get_arg(1)));
unsigned sig_sz = bu.get_bv_size(m.get_sort(a->get_arg(2))) - 1;
rational sgn_q(0), sig_q(0), exp_q(0);
@ -167,14 +167,15 @@ void fpa2bv_model_converter::convert(model * bv_mdl, model * float_mdl) {
it++)
{
func_decl * var = it->m_key;
app * a = to_app(it->m_value);
expr * v = it->m_value;
expr_ref eval_v(m);
SASSERT(fu.is_rm(var->get_range()));
rational val(0);
rational bv_val(0);
unsigned sz = 0;
if (a && bu.is_numeral(a, val, sz)) {
TRACE("fpa2bv_mc", tout << var->get_name() << " == " << val.to_string() << std::endl;);
SASSERT(val.is_uint64());
switch (val.get_uint64())
if (v && bv_mdl->eval(v, eval_v, true) && bu.is_numeral(eval_v, bv_val, sz)) {
TRACE("fpa2bv_mc", tout << var->get_name() << " == " << bv_val.to_string() << std::endl;);
SASSERT(bv_val.is_uint64());
switch (bv_val.get_uint64())
{
case BV_RM_TIES_TO_AWAY: float_mdl->register_decl(var, fu.mk_round_nearest_ties_to_away()); break;
case BV_RM_TIES_TO_EVEN: float_mdl->register_decl(var, fu.mk_round_nearest_ties_to_even()); break;
@ -183,7 +184,8 @@ void fpa2bv_model_converter::convert(model * bv_mdl, model * float_mdl) {
case BV_RM_TO_ZERO:
default: float_mdl->register_decl(var, fu.mk_round_toward_zero());
}
seen.insert(var);
SASSERT(v->get_kind() == AST_APP);
seen.insert(to_app(v)->get_decl());
}
}

View file

@ -96,8 +96,8 @@ class fpa2bv_tactic : public tactic {
g->inc_depth();
result.push_back(g.get());
for (unsigned i = 0; i < m_conv.extra_assertions.size(); i++)
result.back()->assert_expr(m_conv.extra_assertions[i].get());
for (unsigned i = 0; i < m_conv.m_extra_assertions.size(); i++)
result.back()->assert_expr(m_conv.m_extra_assertions[i].get());
SASSERT(g->is_well_sorted());
TRACE("fpa2bv", tout << "AFTER: " << std::endl; g->display(tout);

View file

@ -0,0 +1,100 @@
/*++
Copyright (c) 2012 Microsoft Corporation
Module Name:
qffpa_tactic.cpp
Abstract:
Tactic for QF_FP benchmarks.
Author:
Christoph (cwinter) 2012-01-16
Notes:
--*/
#include"tactical.h"
#include"simplify_tactic.h"
#include"bit_blaster_tactic.h"
#include"sat_tactic.h"
#include"fpa2bv_tactic.h"
#include"smt_tactic.h"
#include"propagate_values_tactic.h"
#include"qffp_tactic.h"
tactic * mk_qffp_tactic(ast_manager & m, params_ref const & p) {
params_ref simp_p = p;
simp_p.set_bool("arith_lhs", true);
simp_p.set_bool("elim_and", true);
tactic * st = and_then(mk_simplify_tactic(m, simp_p),
mk_propagate_values_tactic(m, p),
cond(mk_or(mk_produce_proofs_probe(), mk_produce_unsat_cores_probe()),
mk_smt_tactic(),
and_then(
mk_fpa2bv_tactic(m, p),
using_params(mk_simplify_tactic(m, p), simp_p),
mk_bit_blaster_tactic(m, p),
using_params(mk_simplify_tactic(m, p), simp_p),
cond(mk_is_propositional_probe(),
mk_sat_tactic(m, p),
mk_smt_tactic(p)),
mk_fail_if_undecided_tactic())));
st->updt_params(p);
return st;
}
tactic * mk_qffpbv_tactic(ast_manager & m, params_ref const & p) {
return mk_qffp_tactic(m, p);
}
struct is_non_qffp_predicate {
struct found {};
ast_manager & m;
bv_util bu;
fpa_util fu;
arith_util au;
is_non_qffp_predicate(ast_manager & _m) : m(_m), bu(m), fu(m), au(m) {}
void operator()(var *) { throw found(); }
void operator()(quantifier *) { throw found(); }
void operator()(app * n) {
sort * s = get_sort(n);
if (!m.is_bool(s) && !fu.is_float(s) && !fu.is_rm(s) && !bu.is_bv_sort(s) && !au.is_real(s))
throw found();
family_id fid = n->get_family_id();
if (fid == m.get_basic_family_id())
return;
if (fid == fu.get_family_id() || fid == bu.get_family_id())
return;
if (is_uninterp_const(n))
return;
if (au.is_real(s) && au.is_numeral(n))
return;
throw found();
}
};
class is_qffp_probe : public probe {
public:
virtual result operator()(goal const & g) {
return !test<is_non_qffp_predicate>(g);
}
};
probe * mk_is_qffp_probe() {
return alloc(is_qffp_probe);
}
probe * mk_is_qffpbv_probe() {
return alloc(is_qffp_probe);
}

View file

@ -0,0 +1,41 @@
/*++
Copyright (c) 2012 Microsoft Corporation
Module Name:
qffp_tactic.h
Abstract:
Tactic for QF_FP benchmarks.
Author:
Christoph (cwinter) 2012-01-16
Notes:
--*/
#ifndef _QFFP_TACTIC_H_
#define _QFFP_TACTIC_H_
#include"params.h"
class ast_manager;
class tactic;
tactic * mk_qffp_tactic(ast_manager & m, params_ref const & p = params_ref());
tactic * mk_qffpbv_tactic(ast_manager & m, params_ref const & p = params_ref());
/*
ADD_TACTIC("qffp", "(try to) solve goal using the tactic for QF_FP.", "mk_qffp_tactic(m, p)")
ADD_TACTIC("qffpbv", "(try to) solve goal using the tactic for QF_FPBV (floats+bit-vectors).", "mk_qffpbv_tactic(m, p)")
*/
probe * mk_is_qffp_probe();
probe * mk_is_qffpbv_probe();
/*
ADD_PROBE("is-qffp", "true if the goal is in QF_FP (floats).", "mk_is_qffp_probe()")
ADD_PROBE("is-qffpbv", "true if the goal is in QF_FPBV (floats+bit-vectors).", "mk_is_qffpbv_probe()")
*/
#endif

View file

@ -1,116 +0,0 @@
/*++
Copyright (c) 2012 Microsoft Corporation
Module Name:
qffpa_tactic.cpp
Abstract:
Tactic for QF_FPA benchmarks.
Author:
Christoph (cwinter) 2012-01-16
Notes:
--*/
#include"tactical.h"
#include"simplify_tactic.h"
#include"bit_blaster_tactic.h"
#include"sat_tactic.h"
#include"fpa2bv_tactic.h"
#include"qffpa_tactic.h"
tactic * mk_qffpa_tactic(ast_manager & m, params_ref const & p) {
params_ref sat_simp_p = p;
sat_simp_p .set_bool("elim_and", true);
return and_then(mk_simplify_tactic(m, p),
mk_fpa2bv_tactic(m, p),
using_params(mk_simplify_tactic(m, p), sat_simp_p),
mk_bit_blaster_tactic(m, p),
using_params(mk_simplify_tactic(m, p), sat_simp_p),
mk_sat_tactic(m, p),
mk_fail_if_undecided_tactic());
}
struct is_non_qffpa_predicate {
struct found {};
ast_manager & m;
float_util u;
is_non_qffpa_predicate(ast_manager & _m) : m(_m), u(m) {}
void operator()(var *) { throw found(); }
void operator()(quantifier *) { throw found(); }
void operator()(app * n) {
sort * s = get_sort(n);
if (!m.is_bool(s) && !u.is_float(s) && !u.is_rm(s))
throw found();
family_id fid = n->get_family_id();
if (fid == m.get_basic_family_id())
return;
if (fid == u.get_family_id())
return;
if (is_uninterp_const(n))
return;
throw found();
}
};
struct is_non_qffpabv_predicate {
struct found {};
ast_manager & m;
bv_util bu;
float_util fu;
is_non_qffpabv_predicate(ast_manager & _m) : m(_m), bu(m), fu(m) {}
void operator()(var *) { throw found(); }
void operator()(quantifier *) { throw found(); }
void operator()(app * n) {
sort * s = get_sort(n);
if (!m.is_bool(s) && !fu.is_float(s) && !fu.is_rm(s) && !bu.is_bv_sort(s))
throw found();
family_id fid = n->get_family_id();
if (fid == m.get_basic_family_id())
return;
if (fid == fu.get_family_id() || fid == bu.get_family_id())
return;
if (is_uninterp_const(n))
return;
throw found();
}
};
class is_qffpa_probe : public probe {
public:
virtual result operator()(goal const & g) {
return !test<is_non_qffpa_predicate>(g);
}
};
class is_qffpabv_probe : public probe {
public:
virtual result operator()(goal const & g) {
return !test<is_non_qffpabv_predicate>(g);
}
};
probe * mk_is_qffpa_probe() {
return alloc(is_qffpa_probe);
}
probe * mk_is_qffpabv_probe() {
return alloc(is_qffpabv_probe);
}

View file

@ -1,40 +0,0 @@
/*++
Copyright (c) 2012 Microsoft Corporation
Module Name:
qffpa_tactic.h
Abstract:
Tactic QF_FPA benchmarks.
Author:
Christoph (cwinter) 2012-01-16
Notes:
--*/
#ifndef _QFFPA_TACTIC_H_
#define _QFFPA_TACTIC_H_
#include"params.h"
class ast_manager;
class tactic;
tactic * mk_qffpa_tactic(ast_manager & m, params_ref const & p = params_ref());
/*
ADD_TACTIC("qffpa", "(try to) solve goal using the tactic for QF_FPA.", "mk_qffpa_tactic(m, p)")
ADD_TACTIC("qffpabv", "(try to) solve goal using the tactic for QF_FPABV (floats+bit-vectors).", "mk_qffpa_tactic(m, p)")
*/
probe * mk_is_qffpa_probe();
probe * mk_is_qffpabv_probe();
/*
ADD_PROBE("is-qffpa", "true if the goal is in QF_FPA (FloatingPoints).", "mk_is_qffpa_probe()")
ADD_PROBE("is-qffpabv", "true if the goal is in QF_FPABV (FloatingPoints+Bitvectors).", "mk_is_qffpabv_probe()")
*/
#endif

View file

@ -27,7 +27,7 @@ Notes:
#include"nra_tactic.h"
#include"probe_arith.h"
#include"quant_tactics.h"
#include"qffpa_tactic.h"
#include"qffp_tactic.h"
#include"qfaufbv_tactic.h"
#include"qfauflia_tactic.h"
@ -42,8 +42,8 @@ tactic * mk_default_tactic(ast_manager & m, params_ref const & p) {
cond(mk_is_qfnia_probe(), mk_qfnia_tactic(m),
cond(mk_is_nra_probe(), mk_nra_tactic(m),
cond(mk_is_lira_probe(), mk_lira_tactic(m, p),
cond(mk_is_qffpabv_probe(), mk_qffpa_tactic(m, p),
mk_smt_tactic()))))))))))),
cond(mk_is_qffp_probe(), mk_qffp_tactic(m, p),
mk_smt_tactic()))))))))),
p);
return st;
}

View file

@ -33,7 +33,7 @@ Notes:
#include"qfidl_tactic.h"
#include"default_tactic.h"
#include"ufbv_tactic.h"
#include"qffpa_tactic.h"
#include"qffp_tactic.h"
#include"horn_tactic.h"
#include"smt_solver.h"
@ -78,10 +78,10 @@ tactic * mk_tactic_for_logic(ast_manager & m, params_ref const & p, symbol const
return mk_ufbv_tactic(m, p);
else if (logic=="BV")
return mk_ufbv_tactic(m, p);
else if (logic=="QF_FPA")
return mk_qffpa_tactic(m, p);
else if (logic=="QF_FPABV")
return mk_qffpa_tactic(m, p);
else if (logic=="QF_FP")
return mk_qffp_tactic(m, p);
else if (logic == "QF_FPBV")
return mk_qffpbv_tactic(m, p);
else if (logic=="HORN")
return mk_horn_tactic(m, p);
else