forked from diffblue/cbmc
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request diffblue#1621 from tautschnig/fix-1620
Use stable data structure for BV refinement approximations
- Loading branch information
Showing
4 changed files
with
60 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include <assert.h> | ||
#include <math.h> | ||
|
||
#ifdef __GNUC__ | ||
void inductiveStepHunt (float startState) | ||
{ | ||
float target = 0x1.fffffep-3f; | ||
|
||
__CPROVER_assume((0 < startState) && (fpclassify(startState) == FP_NORMAL) && (0x1p-126f <= startState)); | ||
|
||
float secondPoint = (target / startState); | ||
|
||
float nextState = (startState + secondPoint) / 2; | ||
|
||
float oneAfter = (target / nextState); | ||
|
||
assert(oneAfter > 0); | ||
} | ||
|
||
void simplifiedInductiveStepHunt (float nextState) | ||
{ | ||
float target = 0x1.fffffep-3f; | ||
|
||
// Implies nextState == 0x1p+124f; | ||
__CPROVER_assume((0x1.fffffep+123f < nextState) && (nextState < 0x1.000002p+124f)); | ||
|
||
float oneAfter = (target / nextState); | ||
|
||
// Is true and correctly proven by constant evaluation | ||
// Note that this is the smallest normal number | ||
assert(0x1.fffffep-3f / 0x1p+124f == 0x1p-126f); | ||
|
||
assert(oneAfter > 0); | ||
} | ||
#endif | ||
|
||
int main (void) | ||
{ | ||
#ifdef __GNUC__ | ||
// inductiveStepHunt(0x1p+125f); | ||
// simplifiedInductiveStepHunt(0x1p+124f); | ||
|
||
float f, g; | ||
|
||
inductiveStepHunt(f); | ||
simplifiedInductiveStepHunt(g); | ||
#endif | ||
|
||
return 0; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CORE | ||
main.c | ||
--floatbv --refine | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
^VERIFICATION SUCCESSFUL$ | ||
-- | ||
^warning: ignoring |
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