Datasets:
Download experiments/t2/examples/D02/annotated.c from PV-SJTU/PV-Bench: direct link, hf CLI and curl.
- Browser
- Download file 704 Bytes
-
https://huggingface.co/datasets/PV-SJTU/PV-Bench/resolve/main/experiments/t2/examples/D02/annotated.c
- Command line
-
hf download hf://datasets/PV-SJTU/PV-Bench/experiments/t2/examples/D02/annotated.c
-
curl -L -o annotated.c https://huggingface.co/datasets/PV-SJTU/PV-Bench/resolve/main/experiments/t2/examples/D02/annotated.c
704 Bytes
| /*@ Import Coq Require Import AUXLib.ListLib */ | |
| /*@ Extern Coq (sum : list Z -> Z) */ | |
| unsigned int arr_sum(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) */ | |
| { | |
| int i; | |
| 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 (i = 0; i < n; ++i) { | |
| ret += a[i]; | |
| } | |
| return ret; | |
| } | |