Professional Documents
Culture Documents
Formal Methods - Lecture 14
Formal Methods - Lecture 14
white
Mixed
Mixed
Mixed
Invariant, initial, and termination
condition
(0 r w b N) (i: 0 i < r: red(i))
(i: r i < w: white(i)) (i: b i < N: blue(i))
0 r w b N
Mixed
{Invariant:
0rwbN
(i: 0 i < r: red(i))
(i: r i < w: white(i))
(i: b i < N: blue(i))
Bound Function: b – w}
do w < b
if white(w) w := w + 1;
[] blue(w) swap(b - 1,w); b := b – 1;
[] red(w) swap(r, w); r := r + 1; w := w + 1;
fi
od
{ 0rwN
(i: 0 i < r: red(i))
(i: r i < w: white(i))
(i: w i < N: blue(i))
}