mirror of
https://github.com/Z3Prover/z3
synced 2025-04-25 10:05:32 +00:00
parent
99d7a47f82
commit
cdc8e1303a
6 changed files with 121 additions and 120 deletions
|
@ -54,15 +54,6 @@ void fpa2bv_model_converter::display(std::ostream & out) {
|
|||
out << mk_ismt2_pp(it->m_value.first, m, indent) << "; " <<
|
||||
mk_ismt2_pp(it->m_value.second, m, indent) << ")";
|
||||
}
|
||||
for (obj_hashtable<func_decl>::iterator it = m_unspecified_ufs.begin();
|
||||
it != m_unspecified_ufs.end();
|
||||
it++)
|
||||
{
|
||||
const symbol & n = (*it)->get_name();
|
||||
unsigned indent = n.size() + 4;
|
||||
out << n << " ";
|
||||
}
|
||||
out << ")" << std::endl;
|
||||
}
|
||||
|
||||
model_converter * fpa2bv_model_converter::translate(ast_translation & translator) {
|
||||
|
@ -107,14 +98,6 @@ model_converter * fpa2bv_model_converter::translate(ast_translation & translator
|
|||
translator.to().inc_ref(v1);
|
||||
translator.to().inc_ref(v2);
|
||||
}
|
||||
for (obj_hashtable<func_decl>::iterator it = m_unspecified_ufs.begin();
|
||||
it != m_unspecified_ufs.end();
|
||||
it++)
|
||||
{
|
||||
func_decl * k = translator(*it);
|
||||
res->m_unspecified_ufs.insert(k);
|
||||
translator.to().inc_ref(k);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -337,66 +320,61 @@ void fpa2bv_model_converter::convert(model * bv_mdl, model * float_mdl) {
|
|||
func_decl * f = it->m_key;
|
||||
unsigned arity = f->get_arity();
|
||||
sort * rng = f->get_range();
|
||||
func_interp * flt_fi = alloc(func_interp, m, f->get_arity());
|
||||
|
||||
func_interp * bv_fi = bv_mdl->get_func_interp(it->m_value);
|
||||
SASSERT(bv_fi->args_are_values());
|
||||
if (arity > 0) {
|
||||
func_interp * flt_fi = alloc(func_interp, m, f->get_arity());
|
||||
|
||||
for (unsigned i = 0; i < bv_fi->num_entries(); i++) {
|
||||
func_entry const * bv_fe = bv_fi->get_entry(i);
|
||||
expr * const * bv_args = bv_fe->get_args();
|
||||
expr_ref_buffer new_args(m);
|
||||
func_interp * bv_fi = bv_mdl->get_func_interp(it->m_value);
|
||||
SASSERT(bv_fi->args_are_values());
|
||||
|
||||
for (unsigned j = 0; j < arity; j++) {
|
||||
sort * dj = f->get_domain(j);
|
||||
expr * aj = bv_args[j];
|
||||
if (fu.is_float(dj))
|
||||
new_args.push_back(convert_bv2fp(bv_mdl, dj, aj));
|
||||
else if (fu.is_rm(dj)) {
|
||||
expr_ref fv(m);
|
||||
fv = convert_bv2rm(aj);
|
||||
new_args.push_back(fv);
|
||||
for (unsigned i = 0; i < bv_fi->num_entries(); i++) {
|
||||
func_entry const * bv_fe = bv_fi->get_entry(i);
|
||||
expr * const * bv_args = bv_fe->get_args();
|
||||
expr_ref_buffer new_args(m);
|
||||
|
||||
for (unsigned j = 0; j < arity; j++) {
|
||||
sort * dj = f->get_domain(j);
|
||||
expr * aj = bv_args[j];
|
||||
if (fu.is_float(dj))
|
||||
new_args.push_back(convert_bv2fp(bv_mdl, dj, aj));
|
||||
else if (fu.is_rm(dj)) {
|
||||
expr_ref fv(m);
|
||||
fv = convert_bv2rm(aj);
|
||||
new_args.push_back(fv);
|
||||
}
|
||||
else
|
||||
new_args.push_back(aj);
|
||||
}
|
||||
else
|
||||
new_args.push_back(aj);
|
||||
|
||||
expr_ref ret(m);
|
||||
ret = bv_fe->get_result();
|
||||
if (fu.is_float(rng))
|
||||
ret = convert_bv2fp(bv_mdl, rng, ret);
|
||||
else if (fu.is_rm(rng))
|
||||
ret = convert_bv2rm(ret);
|
||||
|
||||
flt_fi->insert_new_entry(new_args.c_ptr(), ret);
|
||||
}
|
||||
|
||||
expr_ref ret(m);
|
||||
ret = bv_fe->get_result();
|
||||
expr_ref els(m);
|
||||
els = bv_fi->get_else();
|
||||
if (fu.is_float(rng))
|
||||
ret = convert_bv2fp(bv_mdl, rng, ret);
|
||||
els = convert_bv2fp(bv_mdl, rng, els);
|
||||
else if (fu.is_rm(rng))
|
||||
ret = convert_bv2rm(ret);
|
||||
els = convert_bv2rm(els);
|
||||
|
||||
flt_fi->insert_new_entry(new_args.c_ptr(), ret);
|
||||
flt_fi->set_else(els);
|
||||
|
||||
float_mdl->register_decl(f, flt_fi);
|
||||
}
|
||||
|
||||
expr_ref els(m);
|
||||
els = bv_fi->get_else();
|
||||
if (fu.is_float(rng))
|
||||
els = convert_bv2fp(bv_mdl, rng, els);
|
||||
else if (fu.is_rm(rng))
|
||||
els = convert_bv2rm(els);
|
||||
|
||||
flt_fi->set_else(els);
|
||||
|
||||
float_mdl->register_decl(f, flt_fi);
|
||||
}
|
||||
|
||||
// fp.to_*_unspecified UFs.
|
||||
for (obj_hashtable<func_decl>::iterator it = m_unspecified_ufs.begin();
|
||||
it != m_unspecified_ufs.end();
|
||||
it++)
|
||||
{
|
||||
func_decl * f = *it;
|
||||
|
||||
if (bv_mdl->has_interpretation(f)) {
|
||||
func_interp * val = bv_mdl->get_func_interp(f)->copy();
|
||||
TRACE("fpa2bv_mc", tout << "Keeping interpretation for " << mk_ismt2_pp(f, m) << std::endl;);
|
||||
float_mdl->register_decl(f, val);
|
||||
else {
|
||||
func_decl * bvf = it->m_value;
|
||||
expr_ref c(m), e(m);
|
||||
c = m.mk_const(bvf);
|
||||
bv_mdl->eval(c, e, true);
|
||||
float_mdl->register_decl(f, e);
|
||||
TRACE("fpa2bv_mc", tout << "model value for " << mk_ismt2_pp(f, m) << " is " << mk_ismt2_pp(e, m) << std::endl;);
|
||||
}
|
||||
else
|
||||
TRACE("fpa2bv_mc", tout << "No interpretation for " << mk_ismt2_pp(f, m) << std::endl;);
|
||||
}
|
||||
|
||||
// Keep all the non-float constants.
|
||||
|
|
|
@ -28,7 +28,6 @@ class fpa2bv_model_converter : public model_converter {
|
|||
obj_map<func_decl, expr*> m_rm_const2bv;
|
||||
obj_map<func_decl, func_decl*> m_uf2bvuf;
|
||||
obj_map<func_decl, std::pair<app*, app*> > m_specials;
|
||||
obj_hashtable<func_decl> m_unspecified_ufs;
|
||||
|
||||
public:
|
||||
fpa2bv_model_converter(ast_manager & m, fpa2bv_converter const & conv) : m(m) {
|
||||
|
@ -64,13 +63,6 @@ public:
|
|||
m.inc_ref(it->m_value.first);
|
||||
m.inc_ref(it->m_value.second);
|
||||
}
|
||||
for (obj_hashtable<func_decl>::iterator it = conv.m_unspecified_ufs.begin();
|
||||
it != conv.m_unspecified_ufs.end();
|
||||
it++)
|
||||
{
|
||||
m_unspecified_ufs.insert(*it);
|
||||
m.inc_ref(*it);
|
||||
}
|
||||
}
|
||||
|
||||
virtual ~fpa2bv_model_converter() {
|
||||
|
@ -84,7 +76,6 @@ public:
|
|||
m.dec_ref(it->m_value.first);
|
||||
m.dec_ref(it->m_value.second);
|
||||
}
|
||||
dec_ref_collection_values(m, m_unspecified_ufs);
|
||||
}
|
||||
|
||||
virtual void operator()(model_ref & md, unsigned goal_idx) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue