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] Jessie - loop invariant preserved


  • Subject: [Frama-c-discuss] Jessie - loop invariant preserved
  • From: rovedy at ig.com.br (Rovedy Aparecida Busquim e Silva)
  • Date: Fri, 8 Feb 2013 22:16:38 -0200
  • In-reply-to: <1360350128.2293.8.camel@guillaume-laptop>
  • References: <CAEtoXR0gAmzcL4GFrndQX2iwP5koNDy3cK_JdWP15Ze7wBcHWw@mail.gmail.com> <1360350128.2293.8.camel@guillaume-laptop>

Dear Guillaume,

Thanks a lot.

The loop invariant has worked very well.
I have noticed my error.

Best regards,
Rovedy

2013/2/8 Guillaume Melquiond <guillaume.melquiond at inria.fr>

> Le vendredi 08 f?vrier 2013 ? 16:35 -0200, Rovedy Aparecida Busquim e
> Silva a ?crit :
>
> > 1) Is my pos-condition written correctly?
>
> It seems fine, as far as I can tell.
>
> > 2) In this function, there is only a loop. So, the pos-condition is
> > equal to loop invariant, is this right?
>
> No, and that is where your main issue lies. Your loop invariant is just
> plain wrong. A loop invariant has to hold at the start of each iteration
> and at the end of the loop. Yours is true only at the end.
>
> A better invariant (untested) would be
>
> \forall integer j; 0<=j<i ==> G_E[j].G_Inst_Ativ <= Tempo ==>
> G_E[j].G_Ativo == 1;
>
> Notice how occurrences of i were replaced by j and how 0<=i<5 became
> 0<=j<i.
>
> Best regards,
>
> Guillaume
>
>
> _______________________________________________
> Frama-c-discuss mailing list
> Frama-c-discuss at lists.gforge.inria.fr
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/frama-c-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gforge.inria.fr/pipermail/frama-c-discuss/attachments/20130208/8cfe8e32/attachment.html>