-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue while creating model from scratch #7101
Comments
This looks as if the FP simplifier doesn't always propagate NaNs through |
I can see the place in ast\rewriter\fpa_rewriter.cpp that would be relevant, but will have to look up semantics. AI tells me that NaN x 1.5 = NaN, or in other words, the result of multiplication or any other arithmetical operation with NaN is always a NaN. There are also cases for +infinity/-infinity. Could they be simplified? |
Yes, NaNs propagate; if one of the inputs is a NaN, then so is the output. This is not the case for infinities though. At first glance, it looks like the rewriter only rewrites if all of the inputs are numerals, but for NaNs we can do better, because we know the result won't depend on the rounding mode or the other input(s) (but infinities do need to be rounded). In the example provided here, they all are numerals though, so I don't know what else is going wrong there. Maybe the model evaluator doesn't call the FP rewriter at all?! |
Actually, m_util.is_numeral covers also NaN. If I simplify the snippet directly it reduces to true. |
Alright, it isn't a bug with fps. Model evaluation does not necessarily apply simplification. But you can add it:
This suggests you can update the application to ensure full normalization. Not sure if "fixing" this within z3 is necessary or even well-advised. |
Thanks for chasing this down! I also assumed that the model evaluator would always simplify all the way, but you're probably right that it isn't always necessary. |
Digging further: the model.smt2 uses terms of the form (fp ...). These rewrite to fp numerals, but are skipped during model evaluation. Therefore fp.mul etc fail to rewrite them directly. |
One of potential takeaways is that it will be possible to rewrite (fp.mul rm NaN x) to NaN no matter what rm and x. (declare-fun x () (_ FloatingPoint 11 53)) (simplify (assert (not (= (fp.mul roundNearestTiesToEven x (_ NaN 11 53)) (_ NaN 11 53)))) |
Thank you both for fixing this issue! @NikolajBjorner @wintersteiger I'll be testing it on a wider set of formulas. |
Hi,
I'm trying to create a
Z3::model
given a set of equalities (variable == constant) that satisfy a formula. This doesn't always work, and I'm unsure if this is a bug or if I'm incorrectly using the API (4.12.4).My first attempt was to assert the set of equalities in a
z3::solver
and generate a model (s.check(); s.get_model();
). This approach always works without issues.My second attempt aimed to make things faster by creating the model using the
z3::model
API without calling the solver. This approach fails in the following case, and I'm trying to figure out why.The steps to reproduce the issue are:
The steps above show how to reproduce the issue with the second approach (
construct_model_fast
). The formula is not evaluated asTrue
by the model. Instead, it returns:However, if
construct_model_slow
is used, the model correctly evaluates the formula as True.Best,
Manuel.
The text was updated successfully, but these errors were encountered: