source: CIVL/examples/loop_invariants/loop_assigns_given/add.cvl@ 397ae5f

main test-branch
Last change on this file since 397ae5f 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: 442 bytes
Line 
1#pragma CIVL ACSL
2$input int n;
3$assume(n>=1);
4$input int a[n], b[n];
5void f(int n, int *a, int *b, int *c) {
6 /*@ loop invariant 0<=i && i<=n;
7 @ loop invariant \forall int j; 0<=j && j<i ==> c[j]==a[j]+b[j];
8 // @ loop assigns i;
9 @ loop assigns i, c[0 .. (n-1)];
10 @*/
11 for (int i=0; i<n; i++) {
12 c[i] = a[i] + b[i];
13 }
14}
15
16int main() {
17 int c[n];
18 f(n, a, b, c);
19 $assert($forall (int j: 0..n-1) c[j]==a[j]+b[j]);
20}
Note: See TracBrowser for help on using the repository browser.