-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for partially interpreted floating-point functions. Relates to #2596
, #2631.
- Loading branch information
1 parent
1d4f8c0
commit 2308d8a
Showing
7 changed files
with
118 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ Revision History: | |
#include "ast/fpa_decl_plugin.h" | ||
#include "ast/arith_decl_plugin.h" | ||
#include "ast/bv_decl_plugin.h" | ||
#include "ast/ast_smt2_pp.h" | ||
|
||
fpa_decl_plugin::fpa_decl_plugin(): | ||
m_values(m_fm), | ||
|
@@ -68,6 +69,10 @@ void fpa_decl_plugin::recycled_id(unsigned id) { | |
m_fm.del(m_values[id]); | ||
} | ||
|
||
bool fpa_decl_plugin::is_considered_uninterpreted(func_decl * f) { | ||
return false; | ||
} | ||
|
||
func_decl * fpa_decl_plugin::mk_numeral_decl(mpf const & v) { | ||
sort * s = mk_float_sort(v.get_ebits(), v.get_sbits()); | ||
func_decl * r = nullptr; | ||
|
@@ -1044,3 +1049,44 @@ bool fpa_util::contains_floats(ast * a) { | |
|
||
return false; | ||
} | ||
|
||
bool fpa_util::is_considered_uninterpreted(func_decl * f, unsigned n, expr* const* args) { | ||
TRACE("fpa_util", expr_ref t(m().mk_app(f, n, args), m()); tout << mk_ismt2_pp(t, m()) << std::endl; ); | ||
|
||
family_id ffid = plugin().get_family_id(); | ||
if (f->get_family_id() != ffid) | ||
return false; | ||
|
||
if (is_decl_of(f, ffid, OP_FPA_TO_IEEE_BV)) { | ||
SASSERT(n == 1); | ||
expr* x = args[0]; | ||
return is_nan(x); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
wintersteiger
Author
Contributor
|
||
} | ||
else if (is_decl_of(f, ffid, OP_FPA_TO_SBV) || | ||
is_decl_of(f, ffid, OP_FPA_TO_UBV)) { | ||
SASSERT(n == 2); | ||
SASSERT(f->get_num_parameters() == 1); | ||
bool is_signed = f->get_decl_kind() == OP_FPA_TO_SBV; | ||
expr* rm = args[0]; | ||
expr* x = args[1]; | ||
unsigned bv_sz = f->get_parameter(0).get_int(); | ||
mpf_rounding_mode rmv; | ||
mpf v; | ||
if (!is_rm_numeral(rm, rmv) || !is_numeral(x, v)) return false; | ||
if (is_nan(x) || is_inf(x)) return true; | ||
unsynch_mpq_manager& mpqm = plugin().fm().mpq_manager(); | ||
scoped_mpq r(mpqm); | ||
plugin().fm().to_sbv_mpq(rmv, v, r); | ||
if (is_signed) | ||
return mpqm.bitsize(r) >= bv_sz; | ||
else | ||
return mpqm.is_neg(r) || mpqm.bitsize(r) > bv_sz; | ||
} | ||
else if (is_decl_of(f, ffid, OP_FPA_TO_REAL)) { | ||
SASSERT(n == 1); | ||
expr* x = args[0]; | ||
return is_nan(x) || is_inf(x); | ||
} | ||
|
||
return plugin().is_considered_uninterpreted(f); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Hi @wintersteiger , thanks a lot for the fix! I'm testing it now.
Just one question: could we make this NaN case defined as well? AFAIU, the goal of fpa_to_ieee is to produce an exact BV representation of the FP value. If we leave NaN uninterpreted here, then fpa_to_ieee may yield any value for FP NaN, including BV values that don't correspond to NaN. This semantics is not good (not for my usage, at least). Since otherwise there's no way to produce a BV that corresponds to a NaN (I know there are many; I just need one).
Thanks!