source:
CIVL/mods/dev.civl.com/examples/loop_invariants/compare/adder_spec.c@
cb4d4f4
| Last change on this file since cb4d4f4 was aad342c, checked in by , 3 years ago | |
|---|---|
|
|
| File size: 376 bytes | |
| Line | |
|---|---|
| 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.
