-
Notifications
You must be signed in to change notification settings - Fork 53
Allow users to build new rounding mode formulas #508
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
base: master
Are you sure you want to change the base?
Conversation
…eclarationKind and treat them as atomic values instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for noticing and implementing this long-term issue. Roundingmode was clearly a topic that missed some support.
The changes are fine, except two points:
- we only use the existing tests, and I see no new tests. Could you add some test?
- removing public fields from the enum FormulaDeclarationKind is not backwards-compatible, and there was an API change in one method. This is negligible, as we already prepare several API changes within the next release.
Thanks! I'll add some test later today |
src/org/sosy_lab/java_smt/solvers/mathsat5/Mathsat5FormulaCreator.java
Outdated
Show resolved
Hide resolved
Should we add a function to get the rounding mode from a rounding mode formula? We currently have to do something like this, which is rather awkward:
Alternatively we could change the API in
would become:
The original API could then be restored with a default implementation:
|
Another way to implement this is to use indices for the rounding mode. So The downside is that indices have to be constant, so something like |
Hello,
in this PR we add support to explicitly create new rounding mode formulas. So far this has not been possible and rounding-mode formulas were added internally when building new floating-point formulas. This leads to some issues when using visitors on floating-point formulas, as the rounding mode can not be changed when rebuilding the same formula. Let's take the term
(fp.sqrt roundTowardPositive a)
as an example. Here the rounding moderoundTowardPositive
is represented as aFloatingPointRoundingModeFormula
in JavaSMT and can in fact be visited. However, since there is no way to instantiateFloatingPointRoundingModeFormula
, all the visitor can do is return the same rounding mode again. In the same way there is no way to access theFloatingPointRoundingModeFormula
to see which rounding mode is being used by the term.In this PR we add a new method
makeRoundingMode(FloatingPointRoundingMode pRoundingMode)
toFloatingPointFormulaManager
that allows user to create new rounding mode formulas. We also fixed the visitor code in the backends to properly map solver rounding mode values to JavaSMT rounding modes: