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] bug with loop invariant, wrong loop invariant gets proven


  • Subject: [Frama-c-discuss] bug with loop invariant, wrong loop invariant gets proven
  • From: Christoph.Weber at first.fraunhofer.de (Christoph Weber)
  • Date: Thu, 22 Jan 2009 12:29:35 +0100

Hello,

I think I discovered a bug:
Following function:

/*@
 requires 0 < length;
*/
int loopinvariant(int length)
{
// loop 1: proof of false specification 
 int i = 0;
 /*@
     loop invariant 0 <= i < length;
 */
 while(++i != length)
 {}
 
// loop 2: proof failed for intended specification 
 i = 0;
 /*@
     loop invariant 0 <= i <= length;
 */
 while(++i != length)
 {}
 
// loop 3: proof of rewritten loop 2
 i = 0;
 i++;
 /*@
     loop invariant 0 <= i <= length;
 */
 while(i != length)
 {
 i++;
 }
 return 0;
}

As you can see from my comments, I expect loop 2 to be correct.

It is courious, that  a weaker loop invariant fails.

But loop 1 is falsly specifyed but proven never the less.

I think this is of interest and please tell me if I misinterpreted something

Cheers

Christoph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.gforge.inria.fr/pipermail/frama-c-discuss/attachments/20090122/97a0c9c3/attachment.htm