source: CIVL/examples/loop_invariants/compare/adder_spec.c

main
Last change on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
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;
9int 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.