-
Notifications
You must be signed in to change notification settings - Fork 57
Add IEEE-754 Floating Point to Bitvector Conversion Fallback #512
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
Open
baierd
wants to merge
84
commits into
master
Choose a base branch
from
504-ieee-floating-point-to-bitvector-conversion-not-supported-in-all-solvers
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 63 commits
Commits
Show all changes
84 commits
Select commit
Hold shift + click to select a range
6a91ebf
Remove workaround for toIeeeBitvector() in Bitwuzla as the extra cons…
baierd 5c86496
Add fallback for toIeeeBitvector() based on the SMTLIB2 standards sug…
baierd 06e365f
Add extended toIeeeBitvector() fallback implementation with the optio…
baierd d00e534
Add bool manager to all FP managers for new toIeeeBitvector() impl
baierd bc5a5e3
Simplify toIeeeBitvector() fallback implementation
baierd 6e6ec7e
Add CVC4 implementation for getMantissaSize() and getExponentSize()
baierd f584f6b
Add CVC5 implementation for getMantissaSize() and getExponentSize()
baierd 9df8f21
Add Mathsat5 implementation for getMantissaSize() and getExponentSize()
baierd 105e7f2
Add Z3 implementation for getMantissaSize() and getExponentSize()
baierd 4ec7107
Add internal API to retrieve the width of a BV and implement it for a…
baierd 97c1fe4
Add test for FP special number identity for equal precisions
baierd fdaabcc
Add preconditions for FP toIeeeBitvector() method special number mapp…
baierd 3ecd133
Add native Mathsat test for mantissa not including the sign bit with …
baierd 52dbeb5
Add tests for FP toIeeeBitvector() fallback (without custom special n…
baierd 353b12c
Add public API to get exponent and mantissa size in FloatingPointForm…
baierd 6c554d0
Add note about mantissa und sign bit in FloatingPointNumber.java
baierd 9603aa6
Remove accidental double implementation of bitvector width getter
baierd 1f09a65
Use existing BV size getter + make size getters for FP public + exten…
baierd 43ee2a0
Extend delegate FloatingPointManagers with FP size methods
baierd a27cc7e
Rename new FloatingPointFormulaManager method getMantissaSize() to ge…
baierd de90781
Add JavaDoc to FormulaType.FloatingPointType and add methods to get t…
baierd b652b7f
Add JavaDoc to FloatingPointNumber and add methods to get the mantiss…
baierd 11926f1
Add suppression of return value to test method checking native FP to …
baierd 17227ac
Extend FP tests with new mantissa API to be unambiguous about the sig…
baierd 31ffd68
Extend FloatingPointFormulaManager with new mantissa API to be unambi…
baierd 3cc3a99
Rename getMantissaSize() in FloatingPointFormulaManager delegates wit…
baierd cd3a9c1
Update Bitwuzla with new unambiguous FP mantissa size getters
baierd 2fbe5bd
Update CVC4 with new unambiguous FP mantissa size getters
baierd b789362
Update CVC5 with new unambiguous FP mantissa size getters
baierd 2fc661c
Update MathSAT5 with new unambiguous FP mantissa size getters
baierd 7b2b1de
Update Z3 with new unambiguous FP mantissa size getters
baierd dbacf94
Update SolverVisitorTest with new unambiguous FP mantissa size getters
baierd 2d27890
Use mantissa size without sign bit when building special numbers to c…
baierd 15efd20
Fix off-by-one FP mantissa bug when casting BV to FP
baierd ba26c93
Extend FP tests with new tests for toIeeeBitvector() fallback testing…
baierd 9c72a5b
Remove done TODO
baierd 85a5b4e
Rename internal method getMantissaSizeImpl() to getMantissaSizeWithSi…
baierd edf028d
Apply checkstyle and ECJ suggestions
baierd 567e120
Use type information for FP exponent and mantissa in toIeeeBitvector(…
baierd 87a90df
Extend the exception message for parsing failing due to no support fo…
baierd 6fa0b35
Merge branch 'master' into 504-ieee-floating-point-to-bitvector-conve…
baierd 68aa184
Rename "precision" into type for FP types in AbstractFloatingPointFor…
baierd de440e1
Use existing FP type inside toIeeeBitvector() method in AbstractFloat…
baierd 8973957
Remove public methods to get the exponent and mantissa of a FP formula
baierd bfe56ac
Make public methods to get the exponent and mantissa of a FP formula …
baierd aae26af
Remove (new) methods to retrieve FP mantissa and exponent from Abstra…
baierd 95bd69b
Use fp type total size in toIeeeBitvector() instead of building the t…
baierd 638472c
Add null check before getting a message from a caught exception when …
baierd faca8c9
Merge branch 'master' into 504-ieee-floating-point-to-bitvector-conve…
baierd 8f3a60e
Add a toIeeeBitvector() implementation based on 2 parameters; an FP t…
baierd 7b2b45b
Improve JavaDoc of toIeeeBitvector() implementation based on 2 parame…
baierd ddfac9d
Refactor tests for fallback of toIeeeBitvector() to use the version w…
baierd 2fc367e
Remove 2 distinct toIeeeBitvector() fallback methods in favor of the …
baierd 275802e
Re-add accidentally removed JavaDoc of FloatingPointType.getExponentS…
baierd e5e0c81
Remove problematic implementation of (native) FP toIeeeBitvector() in…
baierd 10df745
Add tests for dumping and parsing SMTLIB2 for the Fp to IEEE BV methods
baierd 9a27db3
Improve error message when parsing SMTLIB2 for the Fp to IEEE BV meth…
baierd 1b6a671
Remove boolean manager from FP manager is it is no longer needed
baierd 24230d9
Remove now unused things from BitwuzlaFloatingPointManager
baierd 76ffa33
Access FloatingPointType.getSinglePrecisionFloatingPointType() direct…
baierd 41c0784
Also remove bool manager from solver implementations of FloatingPoint…
baierd f805aeb
Improve JavaDoc of solver native toIeeeBitvector() and its Unsupporte…
baierd a824dac
Improve error msg in case of parsing failure on containing "to_ieee_b…
baierd 2ada968
Switch to requireNativeFPToBitvector() in fpToBvTest instead of using…
baierd 2f98439
Build/get formula type only once when wrapping FP formulas (used in t…
baierd 9e0eee4
Refactor assertions when wrapping FP formulas
baierd f7ac283
Add 2 new FP tests for NaN representation in BV -> FP and FP -> BV
baierd 1b227a2
Update JavaDoc of FloatingPointFormulaManager toIeeeBitvector() fallback
baierd 9f63898
Fix problem with new FP test and add another new FP tests for NaN rep…
baierd 72ad0e3
Merge branch 'master' into 504-ieee-floating-point-to-bitvector-conve…
baierd 1a5e5dc
Rename NaN bit String variable in FP tests
baierd 86c4ab8
Add a FP test for BV -> FP transformation for special FP numbers +-0 …
baierd 914d367
Fix test in FloatingPointFormulaManagerTest in which solvers return e…
baierd dba1560
Format
baierd 31d23af
Merge branch 'master' into 504-ieee-floating-point-to-bitvector-conve…
baierd 45e6c92
Merge branch 'master' into 504-ieee-floating-point-to-bitvector-conve…
baierd e424dfd
Remove Bitwuzla internal tracking for "additional" assertions needed …
baierd 9230799
Remove methods for our internal tracking for "additional" assertions …
baierd a9a111f
Re-use method return in a variable for parsing errors with better err…
baierd 6b97afc
Correct oversight with double conditions for parsing error handling w…
baierd 37d5fce
Move re-throwing of IllegalArgumentException for improved parsing err…
baierd 955c029
Simplify wrapping of FP terms in AbstractFloatingPointFormulaManager
baierd ddc38ce
Simplify wrapping of FP terms in AbstractFloatingPointFormulaManager …
baierd 2405704
Add new method for cases in which checks that dump is parseable is ex…
baierd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
First, there are no "returned values" here. Second, if behavior is simply mentioned as "not defined" it means that probably almost no caller can safely use it without wrapping it in lots of ITEs, creating a trap in the API. After all, the best way to do something should also be the easiest way.
But I suspect that "not defined" is not really true and one can rely on some behavior rules, just that these are more vague than for other operations, right? What are these rules?
For example, can I rely on the fact that if the float is a NaN that there is at least one bv value that is determined as equal to it? And that no bv value that has a defined float representation could compare as equal to a NaN value?
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.
SMTLIB2 applies. Meaning that, from the point of view of SMTLIB2, there is only one NaN etc. The solvers do accept all valid NaN BV representations when transforming from BV to FP as NaN. But they return just one canonical FP NaN representation per default. I added a test for this.
If a user wants custom behavior for special values, it has to be added by the user uniformly over all FPs. (When i realized that, i removed the version of this method that had the ability to add FP number mappings ;D )
Btw. i checked the default BV representations of NaN in all solvers. Some examples:
MathSAT5:
0 11111111 10000000000000000000000Z3:
0 11111111 00000000000000000000001Bitwuzla:
0 11111111 11111111111111111111111CVC5:
1 11111111 11111111111111111111111Uh oh!
There was an error while loading. Please reload this page.
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.
All BV NaN representations seem to work as NaN. When transformed to FP, they are canonized. They do not compare equal as FPs.
Fun fact: no SMT solver returns the same bit representation for NaN as bitvector that is used in the floating-point number when transforming via
toIeeeBitvector().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.
Now the JavaDoc just says "Behavior for special FP values (NaN, Inf, etc.), is solver dependent." Wasn't there an explanation about how to handle this at some point, i.e., the hint to handle special values manually by adding conditions?
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.
Yes, but everyone working with SMT should know how to do this. It might even be dangerous to mention it here; if they don't also modify other sources of BV/FP constants/conversions, unexpected behavior might ensue.
If we knew enough about how these things work or the details, i would be in favor of providing this information. Currently, i don't think that we have the full picture.