Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
39223e3
Minor: Use switch
schuessf Aug 6, 2025
ccd24bb
Add support for __builtin_isinf_sign
schuessf Aug 6, 2025
c25732f
Return ExpressionResult instead of RValue
schuessf Aug 6, 2025
1a66829
Add helper function
schuessf Aug 6, 2025
e0e4141
Add AuxVarInfoBuilder as a parameter
schuessf Aug 11, 2025
63bdab8
Overapproximate some arithmetic float functions
schuessf Aug 11, 2025
73a4810
Add tests
schuessf Aug 11, 2025
9522cf5
Towards a proper API for float functions
schuessf Aug 11, 2025
8034038
Move handling of some functions to MathLibraryModel
schuessf Aug 11, 2025
3283cf0
Support linux functions again
schuessf Aug 11, 2025
330e0e8
Move more function to MathLibraryModel
schuessf Aug 11, 2025
6c011c8
Move handling of float functions to MathLibraryModel
schuessf Aug 12, 2025
23ff49d
Remove FloatFunction (not needed anymore)
schuessf Aug 12, 2025
48d1ae7
Remove unused method, rename method
schuessf Aug 12, 2025
a32c07c
Bugfix: Function names
schuessf Aug 12, 2025
543f4ab
Bugfix: Wrong function
schuessf Aug 12, 2025
1c8eb22
Bugfix: Wrong type
schuessf Aug 12, 2025
727c84a
Move tests that are not supported by MathSAT
schuessf Aug 12, 2025
46a0d13
Make tests slightly easier (to succeed in regression tests)
schuessf Aug 12, 2025
4d851bd
Move number classification macros to MathLibraryModel
schuessf Aug 12, 2025
66aae93
Add comments, minor changes
schuessf Aug 12, 2025
bf7a0d4
Fix typo
schuessf Aug 13, 2025
0b25900
Move TODOs to overapproximated functions
schuessf Aug 13, 2025
d229a66
Overapproximate fmod, restructure TODOs
schuessf Aug 13, 2025
a036861
Pass RoundingMode as expression
schuessf Aug 14, 2025
5ca4edb
Support rounding functions using the current rounding mode
schuessf Aug 14, 2025
90bdd6f
Add more precise overapproximations for signbit and copysign
schuessf Aug 14, 2025
1875505
Remove generic overapproximation handling, overapproximate remainder …
schuessf Aug 14, 2025
f464a71
Move tests from todo to regression again
schuessf Aug 14, 2025
82e5778
Support remainder properly
schuessf Aug 20, 2025
747d8ac
Add proper support for fmod (based on copysign)
schuessf Aug 20, 2025
df06690
Move TODOs into functions
schuessf Aug 20, 2025
1aee24a
Remove assertions that cannot be proven due to overapproximation
schuessf Aug 20, 2025
0a1bd67
Move test that is not supported by MathSAT
schuessf Aug 20, 2025
b6c507e
Move tests, since MathSAT does not support fp.rem
schuessf Aug 20, 2025
9c4d858
Ignore MathSAT crashing because of fp.rem
schuessf Aug 20, 2025
1fde3c0
Fix test and split it to avoid timeouts
schuessf Aug 21, 2025
c460b9a
Fix and split also test for fmod
schuessf Aug 21, 2025
7636f42
Fix formatting of examples
schuessf Aug 22, 2025
5b01a3b
Use assertions from ESMBC tests that should pass
schuessf Aug 22, 2025
e8b7474
Bugfix: Use abs in fmod
schuessf Aug 22, 2025
07e8290
Use remainderf instead of remainder (seems easier for SMT solvers)
schuessf Aug 22, 2025
5064033
Merge branch 'dev' into float-functions
schuessf Sep 30, 2025
65b5143
Fix comment
schuessf Sep 30, 2025
c334a14
Introduce IFloatingPointHandler, more refactoring in BitvectorTransla…
schuessf Oct 1, 2025
6f88a4b
Bugfix: boolean return typess
schuessf Oct 2, 2025
3953fe2
Add headers
schuessf Oct 2, 2025
d973c03
Move interface to own file
schuessf Oct 2, 2025
ee444e8
Store IFloatingPointHandler instance in field
schuessf Oct 2, 2025
2cd309e
Bugfix: Order of arguments
schuessf Oct 6, 2025
f78ba90
Merge branch 'dev' into float-functions
schuessf Oct 6, 2025
a718cdf
Add some documentation
schuessf Oct 6, 2025
b45b622
Update documentation
schuessf Oct 10, 2025
6a390c5
Add comments for outcommented assertions
schuessf Oct 10, 2025
9acfa12
Add timeouts to .testignore
schuessf Oct 10, 2025
47b3e22
Add another timeout to .testignore
schuessf Oct 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions trunk/examples/programs/FloatingPoint/regression/c/all/cos.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// #Safe
/*
* Date: 2025-08-11
* Author: [email protected]
*/

int main() {
float x = __VERIFIER_nondet_float();
float y = cosf(x);
if (isnan(x) && !isnan(y)) reach_error();
if (isinf(x) && !isnan(y)) reach_error();
if (x == 0 && y != 1) reach_error();
if (y > 1 || y < -1) reach_error();
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ int main(void)

x = copysign(NAN, -2.0);
__VERIFIER_assert(isnan(x));
__VERIFIER_assert(signbit(x));
// Due to our overapproximation of signbit for NaN, we currently cannot prove this assertion.
// __VERIFIER_assert(signbit(x));
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ int main(void)
x = -0.0;
rtr = signbit(x);
__VERIFIER_assert(rtr != 0);
x = NAN;
rtr = signbit(x);
__VERIFIER_assert(rtr == 0);
x = 0.0 / 0.0;
rtr = signbit(x);
__VERIFIER_assert(rtr != 0);
// Due to our overapproximation of signbit for NaN, we currently cannot prove these assertions.
// x = NAN;
// rtr = signbit(x);
// __VERIFIER_assert(rtr == 0);
// x = 0.0 / 0.0;
// rtr = signbit(x);
// __VERIFIER_assert(rtr != 0);
return 0;
}
13 changes: 13 additions & 0 deletions trunk/examples/programs/FloatingPoint/regression/c/all/exp.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// #Safe
/*
* Date: 2025-08-11
* Author: [email protected]
*/

int main() {
float x = __VERIFIER_nondet_float();
float y = expf(x);
if (isnan(x) && !isnan(y)) reach_error();
if (x == 0 && y != 1) reach_error();
if (y < 0) reach_error();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// #Safe
/*
* Date: 2025-08-11
* Author: [email protected]
*/

int main() {
int x = __builtin_isinf_sign(5.7);
int y = __builtin_isinf_sign(INFINITY);
int z = __builtin_isinf_sign(-INFINITY);
//@ assert x == 0;
//@ assert y > 0;
//@ assert z < 0;
}
15 changes: 15 additions & 0 deletions trunk/examples/programs/FloatingPoint/regression/c/all/log.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// #Safe
/*
* Date: 2025-08-11
* Author: [email protected]
*/

int main() {
float x = __VERIFIER_nondet_float();
float y = logf(x);
if (isnan(x) && !isnan(y)) reach_error();
if (x == 0 && !isinf(y)) reach_error();
if (x == 1 && y != 0) reach_error();
if (x > 1 && y <= 0) reach_error();
if (x >= 0 && y > x-1) reach_error();
}
14 changes: 14 additions & 0 deletions trunk/examples/programs/FloatingPoint/regression/c/all/sin.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// #Safe
/*
* Date: 2025-08-11
* Author: [email protected]
*/

int main() {
float x = __VERIFIER_nondet_float();
float y = sinf(x);
if (isnan(x) && !isnan(y)) reach_error();
if (isinf(x) && !isnan(y)) reach_error();
if (x == 0 && y != 0) reach_error();
if (y > 1 || y < -1) reach_error();
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,18 @@ TIMEOUT:
- task: ctrans-float-rounding.c
settings: AutomizerC-Reach-32bit-Z3-IcWpLv-Float_Const.epf
toolchain: AutomizerC.xml
- task: ctrans-float-fmod-1.c
settings: AutomizerC-Reach-32bit-Z3-IcWpLv-Float_Const.epf
toolchain: AutomizerC.xml
- task: ctrans-float-fmod-2.c
settings: AutomizerC-Reach-32bit-Z3-IcWpLv-Float_Const.epf
toolchain: AutomizerC.xml
- task: ctrans-float-fmod-3.c
settings: AutomizerC-Reach-32bit-Z3-IcWpLv-Float_Const.epf
toolchain: AutomizerC.xml
- task: ctrans-float-fmod-4.c
settings: AutomizerC-Reach-32bit-Z3-IcWpLv-Float_Const.epf
toolchain: AutomizerC.xml
- task: ctrans-float-fmod-inf.c
settings: AutomizerC-Reach-32bit-WOLF-Float.epf
toolchain: AutomizerC.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//#Safe
/*
https://en.cppreference.com/w/c/numeric/math/fmod
*/

#include <math.h>

extern void __VERIFIER_error() __attribute__ ((__noreturn__));
void __VERIFIER_assert(int cond) { if (!(cond)) { ERROR: __VERIFIER_error(); } return; }

int main(void)
{
__VERIFIER_assert(fmodf(5.1f, 3) == 2.1f);

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//#Safe
/*
https://en.cppreference.com/w/c/numeric/math/fmod
*/

#include <math.h>

extern void __VERIFIER_error() __attribute__ ((__noreturn__));
void __VERIFIER_assert(int cond) { if (!(cond)) { ERROR: __VERIFIER_error(); } return; }

int main(void)
{
__VERIFIER_assert(fmodf(-5.1f, 3) == -2.1f);

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//#Safe
/*
https://en.cppreference.com/w/c/numeric/math/fmod
*/

#include <math.h>

extern void __VERIFIER_error() __attribute__ ((__noreturn__));
void __VERIFIER_assert(int cond) { if (!(cond)) { ERROR: __VERIFIER_error(); } return; }

int main(void)
{
__VERIFIER_assert(fmodf(5.1f, -3) == 2.1f);

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//#Safe
/*
https://en.cppreference.com/w/c/numeric/math/fmod
*/

#include <math.h>

extern void __VERIFIER_error() __attribute__ ((__noreturn__));
void __VERIFIER_assert(int cond) { if (!(cond)) { ERROR: __VERIFIER_error(); } return; }

int main(void)
{
__VERIFIER_assert(fmodf(-5.1f, -3) == -2.1f);

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//#Safe
/*
https://en.cppreference.com/w/c/numeric/math/fmod
*/

#include <math.h>

extern void __VERIFIER_error() __attribute__ ((__noreturn__));
void __VERIFIER_assert(int cond) { if (!(cond)) { ERROR: __VERIFIER_error(); } return; }

int main(void)
{
__VERIFIER_assert(fmod(5.1, INFINITY) == 5.1);
__VERIFIER_assert(fmod(5.1, -INFINITY) == 5.1);

int i = isnan(fmod(INFINITY, 3));
__VERIFIER_assert(i);
i = isnan(fmod(-INFINITY, 3));
__VERIFIER_assert(i);

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//#Safe
/*
https://en.cppreference.com/w/c/numeric/math/fmod
*/

#include <math.h>

extern void __VERIFIER_error() __attribute__ ((__noreturn__));
void __VERIFIER_assert(int cond) { if (!(cond)) { ERROR: __VERIFIER_error(); } return; }

int main(void)
{
int i = isnan(fmod(5.1,0));
__VERIFIER_assert(i);
i = isnan(fmod(5.1,-0));
__VERIFIER_assert(i);

i = isnan(fmod(NAN,3));
__VERIFIER_assert(i);
i = isnan(fmod(5.1,NAN));
__VERIFIER_assert(i);

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//#Safe
/*
https://en.cppreference.com/w/c/numeric/math/remainder
*/

#include <math.h>

extern void __VERIFIER_error() __attribute__ ((__noreturn__));
void __VERIFIER_assert(int cond) { if (!(cond)) { ERROR: __VERIFIER_error(); } return; }

int main(void)
{
__VERIFIER_assert(remainderf(5.1f, 3) == -0x1.ccccdp-1);

return 0;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//#Safe
/*
https://en.cppreference.com/w/c/numeric/math/remainder
*/

#include <math.h>

extern void __VERIFIER_error() __attribute__ ((__noreturn__));
void __VERIFIER_assert(int cond) { if (!(cond)) { ERROR: __VERIFIER_error(); } return; }

int main(void)
{
__VERIFIER_assert(remainderf(5.1f, -3) == -0x1.ccccdp-1);

return 0;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//#Safe
/*
https://en.cppreference.com/w/c/numeric/math/remainder
*/

#include <math.h>

extern void __VERIFIER_error() __attribute__ ((__noreturn__));
void __VERIFIER_assert(int cond) { if (!(cond)) { ERROR: __VERIFIER_error(); } return; }

int main(void)
{
__VERIFIER_assert(remainderf(-5.1f, -3) == 0x1.ccccdp-1);

return 0;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//#Safe
/*
https://en.cppreference.com/w/c/numeric/math/remainder
*/

#include <math.h>

extern void __VERIFIER_error() __attribute__ ((__noreturn__));
void __VERIFIER_assert(int cond) { if (!(cond)) { ERROR: __VERIFIER_error(); } return; }

int main(void)
{
__VERIFIER_assert(remainderf(-5.1f, 3) == 0x1.ccccdp-1);

return 0;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//#Safe
/*
https://en.cppreference.com/w/c/numeric/math/remainder
*/

#include <math.h>

extern void __VERIFIER_error() __attribute__ ((__noreturn__));
void __VERIFIER_assert(int cond) { if (!(cond)) { ERROR: __VERIFIER_error(); } return; }

int main(void)
{
__VERIFIER_assert(remainder(5.1, INFINITY) == 5.1);

int i = isnan(remainder(INFINITY, 3));
__VERIFIER_assert(i);
i = isnan(remainder(-INFINITY, 3));
__VERIFIER_assert(i);

return 0;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//#Safe
/*
https://en.cppreference.com/w/c/numeric/math/remainder
*/

#include <math.h>

extern void __VERIFIER_error() __attribute__ ((__noreturn__));
void __VERIFIER_assert(int cond) { if (!(cond)) { ERROR: __VERIFIER_error(); } return; }

int main(void)
{
int i = isnan(remainder(5.1, 0));
__VERIFIER_assert(i);
i = isnan(remainder(5.1, -0));
__VERIFIER_assert(i);

i = isnan(remainder(NAN, 3));
__VERIFIER_assert(i);
i = isnan(remainder(5.1, NAN));
__VERIFIER_assert(i);

return 0;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//#Safe
/*
https://en.cppreference.com/w/c/numeric/math/remainder
*/

#include <math.h>

extern void __VERIFIER_error() __attribute__ ((__noreturn__));
void __VERIFIER_assert(int cond) { if (!(cond)) { ERROR: __VERIFIER_error(); } return; }

int main(void)
{
double r = remainder(0.0, 1);
__VERIFIER_assert(r == 0 && !signbit(r));
r = remainder(-0.0, 1);
__VERIFIER_assert(r == 0 && signbit(r));

return 0;
}

15 changes: 15 additions & 0 deletions trunk/examples/programs/FloatingPoint/regression/c/noMathSAT/erf.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// #Safe
/*
* Date: 2025-08-11
* Author: [email protected]
*/

int main() {
float x = __VERIFIER_nondet_float();
float y = erff(x);
if (isnan(x) && !isnan(y)) reach_error();
if (isinf(x) && x > 0 && y != 1) reach_error();
if (isinf(x) && x < 0 && y != -1) reach_error();
if (x == 0 && y != 0) reach_error();
if (y > 1 || y < -1) reach_error();
}
Loading