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] Solution to yesterday's quizz
- Subject: [Frama-c-discuss] Solution to yesterday's quizz
- From: Pascal.Cuoq at cea.fr (Pascal Cuoq)
- Date: Fri, 3 Apr 2009 17:00:57 +0200
- In-reply-to: <F1229212CB084F4CBEA197909C8699F1021BD9B7@TLSMAIL1.tls.fr.astrium.corp>
- References: <A6FD74D4A6DA4247AD801E3943634063034C343A@sctex002.st-cloud.dassault-avion.fr><5030C1BB-9A4C-458A-B0CB-DA49C3EABB13@cea.fr><1238682330.7692.339.camel@localhost><3d13dcfc0904020731y7bfae28fo750d100e0fbccf40@mail.gmail.com><1238683464.7692.346.camel@localhost><F1229212CB084F4CBEA197909C8699F1021BD9B5@TLSMAIL1.tls.fr.astrium.corp><20090402183459.41f3b1dd@is005115> <5EFD4D7AC6265F4D9D3A849CEA9219191AB169@LAXA.intra.cea.fr> <F1229212CB084F4CBEA197909C8699F1021BD9B7@TLSMAIL1.tls.fr.astrium.corp>
Here's a formally expressed version of yesterday's quizz: int t[100]; /*@ requires \forall integer k ; 0 <= k < 100 ==> t[k] == 1 ; ensures \forall integer k ; 0 <= k < 100 ==> t[k] == 2 ; */ void f(void) { int i; /* write your invariant here */ for (i=0; i<100; i++) t[i]++; } and my proposed solution is a couple of pages below for those who want to see it: /*@ loop invariant (0 <= i <= 100) && (\forall integer k ; 0 <= k < i ==> t[k] == 2) && (\forall integer k ; i <= k < 100 ==> t[k] == 1) ; */ The loop invariant needs to remember everything that has already been done (the (\forall integer k ; 0 <= k < i ==> t[k] == 2) part) and all the information that will be necessary to make sense of the next iterations, i.e. the fact that the untouched cells still contain 1; that's the (\forall integer k ; i <= k < 100 ==> t[k] == 1) part. Pascal -------------- section suivante -------------- Une pi?ce jointe HTML a ?t? enlev?e... URL: http://lists.gforge.inria.fr/pipermail/frama-c-discuss/attachments/20090403/03077d83/attachment.htm
- References:
- [Frama-c-discuss] Frama-C: GUI's response time
- From: Dillon.Pariente at dassault-aviation.com (Pariente Dillon)
- [Frama-c-discuss] Frama-C: GUI's response time
- From: Pascal.Cuoq at cea.fr (Pascal Cuoq)
- [Frama-c-discuss] Frama-C: GUI's response time
- From: julien.signoles at cea.fr (Julien Signoles)
- [Frama-c-discuss] Frama-C: GUI's response time
- From: dmentre at linux-france.org (David MENTRE)
- [Frama-c-discuss] Frama-C: GUI's response time
- From: julien.signoles at cea.fr (Julien Signoles)
- [Frama-c-discuss] "\at(var, Pre)" before a loop
- From: Thomas.PAREAUD at astrium.eads.net (PAREAUD, Thomas)
- [Frama-c-discuss] "\at(var, Pre)" before a loop
- From: virgile.prevosto at cea.fr (Virgile Prevosto)
- [Frama-c-discuss] "\at(var, Pre)" before a loop
- From: Pascal.CUOQ at cea.fr (CUOQ Pascal)
- [Frama-c-discuss] "\at(var, Pre)" before a loop
- From: Thomas.PAREAUD at astrium.eads.net (PAREAUD, Thomas)
- [Frama-c-discuss] Frama-C: GUI's response time
- Prev by Date: [Frama-c-discuss] "\at(var, Pre)" before a loop
- Next by Date: [Frama-c-discuss] operator %
- Previous by thread: [Frama-c-discuss] "\at(var, Pre)" before a loop
- Next by thread: [Frama-c-discuss] "\at(var, Pre)" before a loop
- Index(es):