@@ -64,22 +64,17 @@ int __CPROVER_islessgreaterd(double f, double g) { return (f < g) || (f > g); }
64
64
65
65
/* FUNCTION: __CPROVER_isunorderedf */
66
66
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
+ }
73
71
74
72
/* FUNCTION: __CPROVER_isunorderedd */
75
73
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
+ }
83
78
84
79
/* FUNCTION: isfinite */
85
80
@@ -363,10 +358,12 @@ inline int __fpclassify(double d) {
363
358
364
359
/* FUNCTION: sin */
365
360
361
+ double __VERIFIER_nondet_double ();
362
+
366
363
double sin (double x )
367
364
{
368
365
// gross over-approximation
369
- double ret ;
366
+ double ret = __VERIFIER_nondet_double () ;
370
367
371
368
if (__CPROVER_isinfd (x ) || __CPROVER_isnand (x ))
372
369
__CPROVER_assume (__CPROVER_isnand (ret ));
@@ -382,10 +379,12 @@ double sin(double x)
382
379
383
380
/* FUNCTION: sinl */
384
381
382
+ long double __VERIFIER_nondet_long_double ();
383
+
385
384
long double sinl (long double x )
386
385
{
387
386
// gross over-approximation
388
- long double ret ;
387
+ long double ret = __VERIFIER_nondet_long_double () ;
389
388
390
389
if (__CPROVER_isinfld (x ) || __CPROVER_isnanld (x ))
391
390
__CPROVER_assume (__CPROVER_isnanld (ret ));
@@ -401,10 +400,12 @@ long double sinl(long double x)
401
400
402
401
/* FUNCTION: sinf */
403
402
403
+ float __VERIFIER_nondet_float ();
404
+
404
405
float sinf (float x )
405
406
{
406
407
// gross over-approximation
407
- float ret ;
408
+ float ret = __VERIFIER_nondet_float () ;
408
409
409
410
if (__CPROVER_isinff (x ) || __CPROVER_isnanf (x ))
410
411
__CPROVER_assume (__CPROVER_isnanf (ret ));
@@ -420,10 +421,12 @@ float sinf(float x)
420
421
421
422
/* FUNCTION: cos */
422
423
424
+ double __VERIFIER_nondet_double ();
425
+
423
426
double cos (double x )
424
427
{
425
428
// gross over-approximation
426
- double ret ;
429
+ double ret = __VERIFIER_nondet_double () ;
427
430
428
431
if (__CPROVER_isinfd (x ) || __CPROVER_isnand (x ))
429
432
__CPROVER_assume (__CPROVER_isnand (ret ));
@@ -439,10 +442,12 @@ double cos(double x)
439
442
440
443
/* FUNCTION: cosl */
441
444
445
+ long double __VERIFIER_nondet_long_double ();
446
+
442
447
long double cosl (long double x )
443
448
{
444
449
// gross over-approximation
445
- long double ret ;
450
+ long double ret = __VERIFIER_nondet_long_double () ;
446
451
447
452
if (__CPROVER_isinfld (x ) || __CPROVER_isnanld (x ))
448
453
__CPROVER_assume (__CPROVER_isnanld (ret ));
@@ -458,11 +463,13 @@ long double cosl(long double x)
458
463
459
464
/* FUNCTION: cosf */
460
465
466
+ float __VERIFIER_nondet_float ();
467
+
461
468
float cosf (float x )
462
469
{
463
470
__CPROVER_hide :;
464
471
// gross over-approximation
465
- float ret ;
472
+ float ret = __VERIFIER_nondet_float () ;
466
473
467
474
if (__CPROVER_isinff (x ) || __CPROVER_isnanf (x ))
468
475
__CPROVER_assume (__CPROVER_isnanf (ret ));
@@ -512,11 +519,6 @@ __CPROVER_hide:;
512
519
513
520
/* FUNCTION: nan */
514
521
515
- #ifndef __CPROVER_MATH_H_INCLUDED
516
- #include <math.h>
517
- #define __CPROVER_MATH_H_INCLUDED
518
- #endif
519
-
520
522
double nan (const char * str ) {
521
523
// the 'str' argument is not yet used
522
524
__CPROVER_hide :;
@@ -526,11 +528,6 @@ double nan(const char *str) {
526
528
527
529
/* FUNCTION: nanf */
528
530
529
- #ifndef __CPROVER_MATH_H_INCLUDED
530
- #include <math.h>
531
- #define __CPROVER_MATH_H_INCLUDED
532
- #endif
533
-
534
531
float nanf (const char * str ) {
535
532
// the 'str' argument is not yet used
536
533
__CPROVER_hide :;
@@ -540,22 +537,13 @@ float nanf(const char *str) {
540
537
541
538
/* FUNCTION: nanl */
542
539
543
- #ifndef __CPROVER_MATH_H_INCLUDED
544
- #include <math.h>
545
- #define __CPROVER_MATH_H_INCLUDED
546
- #endif
547
-
548
540
long double nanl (const char * str ) {
549
541
// the 'str' argument is not yet used
550
542
__CPROVER_hide :;
551
543
(void )* str ;
552
544
return 0.0 /0.0 ;
553
545
}
554
546
555
-
556
-
557
-
558
-
559
547
/* FUNCTION: nextUpf */
560
548
561
549
#ifndef __CPROVER_LIMITS_H_INCLUDED
@@ -738,6 +726,8 @@ __CPROVER_hide:;
738
726
739
727
float nextUpf (float f );
740
728
729
+ float __VERIFIER_nondet_float ();
730
+
741
731
float sqrtf (float f )
742
732
{
743
733
__CPROVER_hide :;
@@ -750,7 +740,7 @@ float sqrtf(float f)
750
740
return f ;
751
741
else if (__CPROVER_isnormalf (f ))
752
742
{
753
- float lower ; // Intentionally non-deterministic
743
+ float lower = __VERIFIER_nondet_float ();
754
744
__CPROVER_assume (lower > 0.0f );
755
745
__CPROVER_assume (__CPROVER_isnormalf (lower ));
756
746
// Tighter bounds can be given but are dependent on the
@@ -795,7 +785,7 @@ float sqrtf(float f)
795
785
// With respect to the algebra of floating point number
796
786
// all subnormals seem to be perfect squares, thus ...
797
787
798
- float root ; // Intentionally non-deterministic
788
+ float root = __VERIFIER_nondet_float ();
799
789
__CPROVER_assume (root >= 0.0f );
800
790
801
791
__CPROVER_assume (root * root == f );
@@ -823,6 +813,8 @@ float sqrtf(float f)
823
813
824
814
double nextUp (double d );
825
815
816
+ double __VERIFIER_nondet_double ();
817
+
826
818
double sqrt (double d )
827
819
{
828
820
__CPROVER_hide :;
@@ -835,7 +827,7 @@ double sqrt(double d)
835
827
return d ;
836
828
else if (__CPROVER_isnormald (d ))
837
829
{
838
- double lower ; // Intentionally non-deterministic
830
+ double lower = __VERIFIER_nondet_double ();
839
831
__CPROVER_assume (lower > 0.0 );
840
832
__CPROVER_assume (__CPROVER_isnormald (lower ));
841
833
@@ -867,7 +859,7 @@ double sqrt(double d)
867
859
//assert(fpclassify(d) == FP_SUBNORMAL);
868
860
//assert(d > 0.0);
869
861
870
- double root ; // Intentionally non-deterministic
862
+ double root = __VERIFIER_nondet_double ();
871
863
__CPROVER_assume (root >= 0.0 );
872
864
873
865
__CPROVER_assume (root * root == d );
@@ -892,6 +884,8 @@ double sqrt(double d)
892
884
893
885
long double nextUpl (long double d );
894
886
887
+ long double __VERIFIER_nondet_long_double ();
888
+
895
889
long double sqrtl (long double d )
896
890
{
897
891
__CPROVER_hide :;
@@ -904,7 +898,7 @@ long double sqrtl(long double d)
904
898
return d ;
905
899
else if (__CPROVER_isnormalld (d ))
906
900
{
907
- long double lower ; // Intentionally non-deterministic
901
+ long double lower = __VERIFIER_nondet_long_double ();
908
902
__CPROVER_assume (lower > 0.0l );
909
903
__CPROVER_assume (__CPROVER_isnormalld (lower ));
910
904
@@ -936,7 +930,7 @@ long double sqrtl(long double d)
936
930
//assert(fpclassify(d) == FP_SUBNORMAL);
937
931
//assert(d > 0.0l);
938
932
939
- long double root ; // Intentionally non-deterministic
933
+ long double root = __VERIFIER_nondet_long_double ();
940
934
__CPROVER_assume (root >= 0.0l );
941
935
942
936
__CPROVER_assume (root * root == d );
@@ -2316,7 +2310,7 @@ long double fabsl (long double d);
2316
2310
2317
2311
long double copysignl (long double x , long double y )
2318
2312
{
2319
- long double abs = fabs (x );
2313
+ long double abs = fabsl (x );
2320
2314
return (signbit (y )) ? - abs : abs ;
2321
2315
}
2322
2316
0 commit comments