# Lecture 06

Q&A session for homeworks and quiz.

Otherwise, you can try to solve this problem as an exercise:

#### Exercise on Arrays

For the next code fragment, do the following

- transform the loop into guarded command language
- construct a formula F(x, x') for the loop body
- write down the loop invariant and show it is inductive with respect to the given pre- and postcondition.

e = a[0]; i = 0; while(i <= n-2) { a[i] = a[i+1]; i = i + 1; } a[n-1] = e