Experiment 1 [Gries 81]: Recover formal specifications
// Sum array b of length n into// variable si := 0; s := 0;while i ? n do { s := s+b[i]; i := i+1 }
Precondition: n ? 0
Postcondition: S = ?0 ? j < n b[j]
Loop invariant: 0 ? i ? n and S = ? 0 ? j < i b[j]
Previous slide
Next slide
Back to first slide
View graphic version