main
test-branch
|
Last change
on this file since a389857 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:
920 bytes
|
| Line | |
|---|
| 1 | /* Verified with mods and invariants:
|
|---|
| 2 | * Changed while loops to for loops
|
|---|
| 3 | */
|
|---|
| 4 | #include <stdlib.h>
|
|---|
| 5 | #include <assert.h>
|
|---|
| 6 | #pragma CIVL ACSL
|
|---|
| 7 | int __VERIFIER_nondet_int(void) {
|
|---|
| 8 | int x;
|
|---|
| 9 | $havoc(&x);
|
|---|
| 10 | return x;
|
|---|
| 11 | }
|
|---|
| 12 | $input int N;
|
|---|
| 13 | /*
|
|---|
| 14 | The program initializes the array 'a' in a loop having loop counter 'i' with a variable 'k' which is a shadow of 'i'. Checks universally quantified property \forall i, a[i] = i.
|
|---|
| 15 | */
|
|---|
| 16 |
|
|---|
| 17 | int main() {
|
|---|
| 18 | if(N>0) {
|
|---|
| 19 | int i,k;
|
|---|
| 20 | int a[N];
|
|---|
| 21 |
|
|---|
| 22 | // modified:
|
|---|
| 23 | k = 0;
|
|---|
| 24 | //@ transform flatten i;
|
|---|
| 25 | /*@ loop invariant 0 <= i && i <= N;
|
|---|
| 26 | @ loop invariant i == k;
|
|---|
| 27 | @*/
|
|---|
| 28 | for (i = 0; i < N; i++) {
|
|---|
| 29 | a[k] = k;
|
|---|
| 30 | k = k+1;
|
|---|
| 31 | }
|
|---|
| 32 | /* original:
|
|---|
| 33 | i=0;
|
|---|
| 34 | k=0;
|
|---|
| 35 | while(i < N) {
|
|---|
| 36 | a[k]=k;
|
|---|
| 37 | i=i+1;
|
|---|
| 38 | k=k+1;
|
|---|
| 39 | }
|
|---|
| 40 | */
|
|---|
| 41 |
|
|---|
| 42 | // modified:
|
|---|
| 43 | //@ transform flatten i;
|
|---|
| 44 | $assert($forall(int i:0..N-1) a[i] == i);
|
|---|
| 45 | /* original:
|
|---|
| 46 | i=0;
|
|---|
| 47 | while(i < N) {
|
|---|
| 48 | __VERIFIER_assert(a[i]==i);
|
|---|
| 49 | i=i+1;
|
|---|
| 50 | }
|
|---|
| 51 | */
|
|---|
| 52 | }
|
|---|
| 53 | return 0;
|
|---|
| 54 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.