PV-Bench / experiments /t2 /examples /D08 /annotated.c
cielseven's picture
regenerate groundtruth with qcp 2.1.4, update the experiment harnesses
2504377
Raw History Blame Contribute Delete
697 Bytes
/*@ Import Coq Require Import AUXLib.ListLib */
/*@ Extern Coq (sum : list Z -> Z) */
unsigned int arr_sum_for(int n, unsigned int *a)
/*@ With l
Require 0 <= n && n < 100 && UIntArray::full(a, n, l) &&
(forall (i: Z), (0 <= i && i < n) => 0 <= l[i] && l[i] < 100)
Ensure __return == sum(l) && UIntArray::full(a, n, l) */
{
unsigned int ret = 0;
/*@ Inv Assert
0 <= n@pre && n@pre < 100 &&
0 <= i && i <= n@pre &&
a == a@pre && n == n@pre &&
(forall (i: Z), (0 <= i && i < n@pre) => 0 <= l[i] && l[i] < 100) &&
ret == sum(sublist(0, i, l)) &&
UIntArray::full(a, n, l)
*/
for (int i = 0; i < n; ++i)
ret += a[i];
return ret;
}