-
Notifications
You must be signed in to change notification settings - Fork 291
smt2: flatten FPA-encoded floats to their IEEE bit pattern #9031
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
tautschnig
wants to merge
1
commit into
diffblue:develop
Choose a base branch
from
tautschnig:flatten-fpa
base: develop
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.
+205
−5
Open
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| #include <stdint.h> | ||
|
|
||
| // Exercises smt2_convt::flatten2bv on an FPA-encoded `double`: reading the | ||
| // bytes of a double through a union forces the SMT2 back-end to turn the | ||
| // floating-point value into its IEEE-754 interchange bit pattern. The | ||
| // SMT-LIB FloatingPoint theory has no float-to-bit-vector operation, so | ||
| // before this was supported the cprover-smt2 / FPA path hit an invariant | ||
| // here. `--no-simplify` keeps the constant from being folded away before | ||
| // it reaches the back-end, so the flattening code is actually exercised. | ||
| // | ||
| // The check is meaningful primarily under the cprover-smt2 profile (FPA | ||
| // theory); under the SAT back-end the value is bit-vector-encoded anyway, | ||
| // in which case the assertions simply hold. | ||
|
|
||
| int main(void) | ||
| { | ||
| union | ||
| { | ||
| double d; | ||
| uint64_t bits; | ||
| } u; | ||
|
|
||
| u.d = 1.0; | ||
| __CPROVER_assert(u.bits == 0x3FF0000000000000ull, "IEEE-754 bits of 1.0"); | ||
|
|
||
| u.d = -2.0; | ||
| __CPROVER_assert(u.bits == 0xC000000000000000ull, "IEEE-754 bits of -2.0"); | ||
|
|
||
| u.d = 0.0; | ||
| __CPROVER_assert(u.bits == 0x0000000000000000ull, "IEEE-754 bits of 0.0"); | ||
|
|
||
| return 0; | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| CORE broken-cprover-smt-backend | ||
| main.c | ||
| --floatbv --no-simplify | ||
| ^EXIT=0$ | ||
| ^SIGNAL=0$ | ||
| ^VERIFICATION SUCCESSFUL$ | ||
| -- | ||
| ^warning: ignoring | ||
| -- | ||
| End-to-end documentation of the user-visible scenario that motivated | ||
| the new `flatten2bv` handling: reading the IEEE-754 bit pattern of | ||
| an FPA-encoded `double` through a union. The SMT-LIB FloatingPoint | ||
| theory has no float-to-bit-vector operation, so under FPA the | ||
| cprover-smt2 / `--smt2 --fpa` path previously hit an invariant here. | ||
|
|
||
| `--no-simplify` keeps the constant union read from being folded | ||
| away before it reaches the SMT2 back-end. `double` is IEEE | ||
| binary64 on every supported target, so no architecture pinning is | ||
| needed. | ||
|
|
||
| The test is tagged `broken-cprover-smt-backend` because CPROVER's | ||
| in-tree SMT2 solver does not fully support the SMT-LIB | ||
| FloatingPoint theory beyond constant folding: even with the new | ||
| flatten2bv path it returns "ERROR" on assertions involving | ||
| FPA-encoded values, which is a solver-side limitation. Under the | ||
| SAT and incremental-SMT2 (z3) CI profiles `use_FPA_theory` is | ||
| false, so the new code path is not exercised by this regression | ||
| test in CI; that coverage lives in `unit/solvers/smt2/smt2_conv.cpp` | ||
| ("flatten2bv FPA-encoded float ..." test cases), which drive | ||
| `flatten2bv` directly with `use_FPA_theory == true` and abort | ||
| without the fix. This regression test still passes under the SAT | ||
| and incremental-SMT2 (z3) profiles via the bv-encoded path, and | ||
| has been confirmed manually under `--z3 --fpa` to be | ||
| solver-compatible. |
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
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.
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.
Uh oh!
There was an error while loading. Please reload this page.