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] Specification Examples


  • Subject: [Frama-c-discuss] Specification Examples
  • From: Claude.Marche at inria.fr (Claude Marché)
  • Date: Thu Oct 9 16:18:16 2008
  • In-reply-to: <4FA912B7D4D8468FBACF5B5DDE198385@AHARDPLACE>
  • References: <4FA912B7D4D8468FBACF5B5DDE198385@AHARDPLACE>


Christoph Weber wrote:
> #2: in the second example the preservation of the loop invariant wont work
> 
> 
> 
> /*@ 
>  requires 0 < n;  
>  requires \valid_range(a, 0, n-1) && \valid_range(b, 0, n-1);
>  ensures  \forall int k; 0 <= k < n ==> a[k] == b[k];
> */
> void array_cpy(int* a, int n, int* b){ 
>  /*@ loop invariant 0 <= i <= n && \forall int m; 0 <= m < i  ==> a[m] == b[m];
>  */
>  for(int i = 0;i< n;i++){    
>   a[i]=b[i];    
>  } 
> }
> 
> 
> What am I missing, to get the examples running?

You must take into account the fact that arrays a and b might overlap, 
such as if you call array_cpy as

   array_cpy(t,10,t+1);

in such a case your spec does not hold I think.

- Claude

-- 
Claude March?                          | tel: +33 1 72 92 59 69
INRIA Saclay - ?le-de-France           | mobile: +33 6 33 14 57 93
Parc Orsay Universit?                  | fax: +33 1 74 85 42 29
4, rue Jacques Monod - B?timent N      | http://www.lri.fr/~marche/
F-91893 ORSAY Cedex                    |