@@ -64,22 +64,17 @@ int __CPROVER_islessgreaterd(double f, double g) { return (f < g) || (f > g); }
6464
6565/* FUNCTION: __CPROVER_isunorderedf */
6666
67- #ifndef __CPROVER_MATH_H_INCLUDED
68- #include <math.h>
69- #define __CPROVER_MATH_H_INCLUDED
70- #endif
71-
72- int __CPROVER_isunorderedf (float f , float g ) { return isnanf (f ) || isnanf (g ); }
67+ int __CPROVER_isunorderedf (float f , float g )
68+ {
69+ return __CPROVER_isnanf (f ) || __CPROVER_isnanf (g );
70+ }
7371
7472/* FUNCTION: __CPROVER_isunorderedd */
7573
76- #ifndef __CPROVER_MATH_H_INCLUDED
77- #include <math.h>
78- #define __CPROVER_MATH_H_INCLUDED
79- #endif
80-
81- int __CPROVER_isunorderedd (double f , double g ) { return isnan (f ) || isnan (g ); }
82-
74+ int __CPROVER_isunorderedd (double f , double g )
75+ {
76+ return __CPROVER_isnand (f ) || __CPROVER_isnand (g );
77+ }
8378
8479/* FUNCTION: isfinite */
8580
@@ -363,10 +358,12 @@ inline int __fpclassify(double d) {
363358
364359/* FUNCTION: sin */
365360
361+ double __VERIFIER_nondet_double ();
362+
366363double sin (double x )
367364{
368365 // gross over-approximation
369- double ret ;
366+ double ret = __VERIFIER_nondet_double () ;
370367
371368 if (__CPROVER_isinfd (x ) || __CPROVER_isnand (x ))
372369 __CPROVER_assume (__CPROVER_isnand (ret ));
@@ -382,10 +379,12 @@ double sin(double x)
382379
383380/* FUNCTION: sinl */
384381
382+ long double __VERIFIER_nondet_long_double ();
383+
385384long double sinl (long double x )
386385{
387386 // gross over-approximation
388- long double ret ;
387+ long double ret = __VERIFIER_nondet_long_double () ;
389388
390389 if (__CPROVER_isinfld (x ) || __CPROVER_isnanld (x ))
391390 __CPROVER_assume (__CPROVER_isnanld (ret ));
@@ -401,10 +400,12 @@ long double sinl(long double x)
401400
402401/* FUNCTION: sinf */
403402
403+ float __VERIFIER_nondet_float ();
404+
404405float sinf (float x )
405406{
406407 // gross over-approximation
407- float ret ;
408+ float ret = __VERIFIER_nondet_float () ;
408409
409410 if (__CPROVER_isinff (x ) || __CPROVER_isnanf (x ))
410411 __CPROVER_assume (__CPROVER_isnanf (ret ));
@@ -420,10 +421,12 @@ float sinf(float x)
420421
421422/* FUNCTION: cos */
422423
424+ double __VERIFIER_nondet_double ();
425+
423426double cos (double x )
424427{
425428 // gross over-approximation
426- double ret ;
429+ double ret = __VERIFIER_nondet_double () ;
427430
428431 if (__CPROVER_isinfd (x ) || __CPROVER_isnand (x ))
429432 __CPROVER_assume (__CPROVER_isnand (ret ));
@@ -439,10 +442,12 @@ double cos(double x)
439442
440443/* FUNCTION: cosl */
441444
445+ long double __VERIFIER_nondet_long_double ();
446+
442447long double cosl (long double x )
443448{
444449 // gross over-approximation
445- long double ret ;
450+ long double ret = __VERIFIER_nondet_long_double () ;
446451
447452 if (__CPROVER_isinfld (x ) || __CPROVER_isnanld (x ))
448453 __CPROVER_assume (__CPROVER_isnanld (ret ));
@@ -458,11 +463,13 @@ long double cosl(long double x)
458463
459464/* FUNCTION: cosf */
460465
466+ float __VERIFIER_nondet_float ();
467+
461468float cosf (float x )
462469{
463470__CPROVER_hide :;
464471 // gross over-approximation
465- float ret ;
472+ float ret = __VERIFIER_nondet_float () ;
466473
467474 if (__CPROVER_isinff (x ) || __CPROVER_isnanf (x ))
468475 __CPROVER_assume (__CPROVER_isnanf (ret ));
@@ -512,11 +519,6 @@ __CPROVER_hide:;
512519
513520/* FUNCTION: nan */
514521
515- #ifndef __CPROVER_MATH_H_INCLUDED
516- #include <math.h>
517- #define __CPROVER_MATH_H_INCLUDED
518- #endif
519-
520522double nan (const char * str ) {
521523 // the 'str' argument is not yet used
522524 __CPROVER_hide :;
@@ -526,11 +528,6 @@ double nan(const char *str) {
526528
527529/* FUNCTION: nanf */
528530
529- #ifndef __CPROVER_MATH_H_INCLUDED
530- #include <math.h>
531- #define __CPROVER_MATH_H_INCLUDED
532- #endif
533-
534531float nanf (const char * str ) {
535532 // the 'str' argument is not yet used
536533 __CPROVER_hide :;
@@ -540,22 +537,13 @@ float nanf(const char *str) {
540537
541538/* FUNCTION: nanl */
542539
543- #ifndef __CPROVER_MATH_H_INCLUDED
544- #include <math.h>
545- #define __CPROVER_MATH_H_INCLUDED
546- #endif
547-
548540long double nanl (const char * str ) {
549541 // the 'str' argument is not yet used
550542 __CPROVER_hide :;
551543 (void )* str ;
552544 return 0.0 /0.0 ;
553545}
554546
555-
556-
557-
558-
559547/* FUNCTION: nextUpf */
560548
561549#ifndef __CPROVER_LIMITS_H_INCLUDED
@@ -738,6 +726,8 @@ __CPROVER_hide:;
738726
739727float nextUpf (float f );
740728
729+ float __VERIFIER_nondet_float ();
730+
741731float sqrtf (float f )
742732{
743733 __CPROVER_hide :;
@@ -750,7 +740,7 @@ float sqrtf(float f)
750740 return f ;
751741 else if (__CPROVER_isnormalf (f ))
752742 {
753- float lower ; // Intentionally non-deterministic
743+ float lower = __VERIFIER_nondet_float ();
754744 __CPROVER_assume (lower > 0.0f );
755745 __CPROVER_assume (__CPROVER_isnormalf (lower ));
756746 // Tighter bounds can be given but are dependent on the
@@ -795,7 +785,7 @@ float sqrtf(float f)
795785 // With respect to the algebra of floating point number
796786 // all subnormals seem to be perfect squares, thus ...
797787
798- float root ; // Intentionally non-deterministic
788+ float root = __VERIFIER_nondet_float ();
799789 __CPROVER_assume (root >= 0.0f );
800790
801791 __CPROVER_assume (root * root == f );
@@ -823,6 +813,8 @@ float sqrtf(float f)
823813
824814double nextUp (double d );
825815
816+ double __VERIFIER_nondet_double ();
817+
826818double sqrt (double d )
827819{
828820 __CPROVER_hide :;
@@ -835,7 +827,7 @@ double sqrt(double d)
835827 return d ;
836828 else if (__CPROVER_isnormald (d ))
837829 {
838- double lower ; // Intentionally non-deterministic
830+ double lower = __VERIFIER_nondet_double ();
839831 __CPROVER_assume (lower > 0.0 );
840832 __CPROVER_assume (__CPROVER_isnormald (lower ));
841833
@@ -867,7 +859,7 @@ double sqrt(double d)
867859 //assert(fpclassify(d) == FP_SUBNORMAL);
868860 //assert(d > 0.0);
869861
870- double root ; // Intentionally non-deterministic
862+ double root = __VERIFIER_nondet_double ();
871863 __CPROVER_assume (root >= 0.0 );
872864
873865 __CPROVER_assume (root * root == d );
@@ -892,6 +884,8 @@ double sqrt(double d)
892884
893885long double nextUpl (long double d );
894886
887+ long double __VERIFIER_nondet_long_double ();
888+
895889long double sqrtl (long double d )
896890{
897891 __CPROVER_hide :;
@@ -904,7 +898,7 @@ long double sqrtl(long double d)
904898 return d ;
905899 else if (__CPROVER_isnormalld (d ))
906900 {
907- long double lower ; // Intentionally non-deterministic
901+ long double lower = __VERIFIER_nondet_long_double ();
908902 __CPROVER_assume (lower > 0.0l );
909903 __CPROVER_assume (__CPROVER_isnormalld (lower ));
910904
@@ -936,7 +930,7 @@ long double sqrtl(long double d)
936930 //assert(fpclassify(d) == FP_SUBNORMAL);
937931 //assert(d > 0.0l);
938932
939- long double root ; // Intentionally non-deterministic
933+ long double root = __VERIFIER_nondet_long_double ();
940934 __CPROVER_assume (root >= 0.0l );
941935
942936 __CPROVER_assume (root * root == d );
@@ -2316,7 +2310,7 @@ long double fabsl (long double d);
23162310
23172311long double copysignl (long double x , long double y )
23182312{
2319- long double abs = fabs (x );
2313+ long double abs = fabsl (x );
23202314 return (signbit (y )) ? - abs : abs ;
23212315}
23222316
0 commit comments