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] pointer/array issue
- Subject: [Frama-c-discuss] pointer/array issue
- From: virgile.prevosto at cea.fr (Virgile Prevosto)
- Date: Wed, 30 Nov 2011 15:38:48 +0100
- In-reply-to: <31902097-FACD-4679-9C62-73267E2D8591@udel.edu>
- References: <7BAFF59B-AA79-4F29-83A8-044C1466E82C@UDel.Edu> <CAOH62JiDQTes35ueRGd2M60GnxE9GKv-Kz1psANTo5auVdwtBg@mail.gmail.com> <CAM6WbQfg_GqA+VsQVvxywJw6RY_0aYYX91XtUx0urahjwETJGA@mail.gmail.com> <392D90D4-56AD-4A21-9865-BEBE5D04546A@udel.edu> <CAM6WbQcs6k++LgnEhAaknFmc9fBPEfcyx=E_z7B4i_YR9U=Q3A@mail.gmail.com> <F0793D8F-8337-4DD4-A379-E816EA5991F4@udel.edu> <CAM6WbQc89+2xrYgEfDkFcUVi7gAT_qCqyC+PrK_HojH97mC=ow@mail.gmail.com> <1447A980-94B1-4EA1-B7B3-9A9B55F2C056@udel.edu> <5E3974C2-BABB-4BBD-AC11-0AD7D4193E40@first.fraunhofer.de> <31902097-FACD-4679-9C62-73267E2D8591@udel.edu>
Hello, On 29/11/2011 19:39, Stephen Siegel wrote: > Below is an example that comes with the textbook Rigorous Software Development. > partition_swap_permut.c:32:[kernel] user error: invalid implicit conversion from 'int *' to 'int []' in annotation. > [kernel] user error: skipping file "partition_swap_permut.c" that has errors. > [kernel] Frama-C aborted because of invalid user input. > r > > I fixed this is a few other examples by just changing the parameter > type in the predicate to the pointer type. However, in this example, I'm > not sure if that fix will work. The problem is that in the definition of > Permut, there is a bound variable "a" of type "int[]" used in the > universal quantifier. I don't think I want to quantify over "int*". Any > suggestions? Having Permut and Swap act on pointers instead of arrays is indeed the correct way to do it. I can understand your concern about the universal quantification over pointers, that do not have a clean mathematical counterpart, but the definition will nevertheless be correct (in order to prove Permut{L1,L2}(a,l,h) for L1 != L2, you'll need to have access the elements *(a+(l..h)), on which you are able to say something non-trivial[1] only if \valid(a+(l..h)) holds) However, if it makes you feel more comfortable, you can explicit guards in your cases saying exactly that you consider only valid pointers: /*@ inductive Permut{L1,L2}(int a*, integer l, integer h) { case Permut_refl{L}: \forall int a*, integer l, h; \at(\valid(a+(l..h)),L) ==> Permut{L,L}(a, l, h) ; case Permut_sym{L1,L2}: \forall int a*, integer l, h; \at(\valid(a+(l..h)),L1) && \at(\valid(a+(l..h)),L2) ==> Permut{L1,L2}(a, l, h) ==> Permut{L2,L1}(a, l, h) ; case Permut_trans{L1,L2,L3}: \forall int a*, integer l, h; \at(\valid(a+(l..h)),L1) && \at(\valid(a+(l..h)),L2) && \at(\valid(a+(l..h)),L3) ==> Permut{L1,L2}(a, l, h)&& Permut{L2,L3}(a, l, h) ==> Permut{L1,L3}(a, l, h) ; case Permut_swap{L1,L2}: \forall int a*, integer l, h, i, j; \at(\valid(a+(l..h)),L1) && \at(\valid(a+(l..h)),L2) ==> l<= i<= h&& l<= j<= h&& Swap{L1,L2}(a, i, j) ==> Permut{L1,L2}(a, l, h) ; } @*/ Best regards, -- E tutto per oggi, a la prossima volta Virgile [1] other than e.g. *(a+i) == *(a+i) that holds whatever a and i are.
- References:
- [Frama-c-discuss] installing Nitrogen release on Mac
- From: siegel at udel.edu (Stephen Siegel)
- [Frama-c-discuss] installing Nitrogen release on Mac
- From: pascal.cuoq at gmail.com (Pascal Cuoq)
- [Frama-c-discuss] installing Nitrogen release on Mac
- From: ismael.vb at gmail.com (Ismael Vilas Boas)
- [Frama-c-discuss] installing Nitrogen release on Mac
- From: siegel at udel.edu (Stephen Siegel)
- [Frama-c-discuss] installing Nitrogen release on Mac
- From: ismael.vb at gmail.com (Ismael Vilas Boas)
- [Frama-c-discuss] installing Nitrogen release on Mac
- From: siegel at udel.edu (Stephen Siegel)
- [Frama-c-discuss] installing Nitrogen release on Mac
- From: ismael.vb at gmail.com (Ismael Vilas Boas)
- [Frama-c-discuss] adding a new prover
- From: siegel at udel.edu (Stephen Siegel)
- [Frama-c-discuss] adding a new prover
- From: jens.gerlach at first.fraunhofer.de (Jens Gerlach)
- [Frama-c-discuss] pointer/array issue
- From: siegel at udel.edu (Stephen Siegel)
- [Frama-c-discuss] installing Nitrogen release on Mac
- Prev by Date: [Frama-c-discuss] \Old struct value
- Next by Date: [Frama-c-discuss] Frama-C plug-in
- Previous by thread: [Frama-c-discuss] \Old struct value
- Next by thread: [Frama-c-discuss] installing Nitrogen release on Mac
- Index(es):