source:
CIVL/examples/loop_invariants/compare/adder_spec.c@
cc8e265
| Last change on this file since cc8e265 was 97b16c8, checked in by , 8 years ago | |
|---|---|
|
|
| File size: 376 bytes | |
| Rev | Line | |
|---|---|---|
| [97b16c8] | 1 | #include<stdio.h> |
| 2 | #include<stdlib.h> | |
| 3 | #include <civlc.cvh> | |
| 4 | #pragma CIVL ACSL | |
| 5 | $input int N; | |
| 6 | $assume(N >= 0); | |
| 7 | $input int a[N]; | |
| 8 | $output double sum_out; | |
| 9 | int main() { | |
| 10 | double sum = 0; | |
| 11 | /*@ loop invariant 0 <= i <= N; | |
| 12 | @ loop invariant sum == \sum(0, i-1, \lambda int t; a[t]); | |
| 13 | @*/ | |
| 14 | for (int i=0; i<N; i++) sum += a[i]; | |
| 15 | printf("spec: sum=%lf\n", sum); | |
| 16 | sum_out = sum; | |
| 17 | } |
Note:
See TracBrowser
for help on using the repository browser.
