Frama-C-discuss mailing list archives

This page gathers the archives of the old Frama-C-discuss archives, that was hosted by Inria's gforge before its demise at the end of 2020. To search for mails newer than September 2020, please visit the page of the new mailing list on Renater.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Frama-c-discuss] Use of Jessie and Value Analysis plug-in

Le vendredi 19 ao?t 2011 ? 19:00 -0300, Rovedy Aparecida Busquim e Silva
a ?crit :

> 1) Sorry for my mistake. I am sending the function with the new
> annotations (2 versions) but the VCs related with ensures
> clauses aren't proved.
> /*@ assigns \nothing;
>   @*/
> extern double fabs(double) ;
> #define LIMIT    6.111111e-2
>  #pragma JessieFloatModel(defensive)
> /*@ requires \valid(AB_Ptr) && \valid(CD_Ptr);
>   @ assigns *AB_Ptr, *CD_Ptr;
>   @ ensures -6.111111e-2 <= *AB_Ptr <= 6.111111e-2;
>   @ ensures -6.111111e-2 <= *CD_Ptr <= 6.111111e-2;
>   @ */

This is not sufficient to prove your function. In particular, fabs is
underspecified. If I were to plug into your program an fabs function
that returns a value smaller than the absolute value, then your
limitValue would obviously return values that are invalid with respect
to your postcondition. So you should at least change the specification
of fabs to

        /*@ assigns \nothing;
          @ ensures \result == \abs(x);
        extern double fabs(double x);

Even then, your limitValue function would still return broken values.
This is due to 6.111111e-2 not being exactly representable as a
floating-point value. And to make it worse, most (if not all) compilers
will choose to replace it by the floating-point number just above. As a
consequence, if you pass 6.111111e-2 (as a floating-point value) to your
function, it will return a value greater than 6.111111e-2 (as a real

So you have to account for this in your program (or in your
specification). Once you have done so, your program is finally correct
and you can start proving it. Unfortunately, I don't know of any
automatic tool that can prove the correctness of this kind of C code
without some human help. (I would be glad to be proven wrong though.)

Best regards,