Skip to content

Commit 386a3bc

Browse files
author
Daniel Kroening
authored
Merge pull request diffblue#1621 from tautschnig/fix-1620
Use stable data structure for BV refinement approximations
2 parents 79defb5 + 54f987b commit 386a3bc

File tree

4 files changed

+60
-2
lines changed

4 files changed

+60
-2
lines changed
+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#include <assert.h>
2+
#include <math.h>
3+
4+
#ifdef __GNUC__
5+
void inductiveStepHunt (float startState)
6+
{
7+
float target = 0x1.fffffep-3f;
8+
9+
__CPROVER_assume((0 < startState) && (fpclassify(startState) == FP_NORMAL) && (0x1p-126f <= startState));
10+
11+
float secondPoint = (target / startState);
12+
13+
float nextState = (startState + secondPoint) / 2;
14+
15+
float oneAfter = (target / nextState);
16+
17+
assert(oneAfter > 0);
18+
}
19+
20+
void simplifiedInductiveStepHunt (float nextState)
21+
{
22+
float target = 0x1.fffffep-3f;
23+
24+
// Implies nextState == 0x1p+124f;
25+
__CPROVER_assume((0x1.fffffep+123f < nextState) && (nextState < 0x1.000002p+124f));
26+
27+
float oneAfter = (target / nextState);
28+
29+
// Is true and correctly proven by constant evaluation
30+
// Note that this is the smallest normal number
31+
assert(0x1.fffffep-3f / 0x1p+124f == 0x1p-126f);
32+
33+
assert(oneAfter > 0);
34+
}
35+
#endif
36+
37+
int main (void)
38+
{
39+
#ifdef __GNUC__
40+
// inductiveStepHunt(0x1p+125f);
41+
// simplifiedInductiveStepHunt(0x1p+124f);
42+
43+
float f, g;
44+
45+
inductiveStepHunt(f);
46+
simplifiedInductiveStepHunt(g);
47+
#endif
48+
49+
return 0;
50+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--floatbv --refine
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

src/solvers/refinement/bv_refinement.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class bv_refinementt:public bv_pointerst
108108
// MEMBERS
109109

110110
bool progress;
111-
std::vector<approximationt> approximations;
111+
std::list<approximationt> approximations;
112112
bvt parent_assumptions;
113113
protected:
114114
// use gui format

src/solvers/refinement/refine_arithmetic.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ bv_refinementt::add_approximation(
487487
const exprt &expr, bvt &bv)
488488
{
489489
approximations.push_back(approximationt(approximations.size()));
490-
approximationt &a=approximations.back(); // stable!
490+
approximationt &a=approximations.back();
491491

492492
std::size_t width=boolbv_width(expr.type());
493493
PRECONDITION(width!=0);

0 commit comments

Comments
 (0)