CS 641 meeting -*- Outline -*- * repetition (2.8) treat while loop as sugar for a recursion example of extending core language semantics to bigger language ------------------------ THE REPETITION A loop L = while b do c od is translated into: proc L() (?~b [] ?b; c; L) ------------------------ If we had higher order procedures we'd only need one loop proc, but as it is, we need one for each loop Thm: Let p be a predicate and vf \in X -> Integers a state function such that: (all m \in Integers :: {p /\ b /\ vf <= m} c {p /\ vf < m /\ m >= 0}) Then {p} L {p /\ ~b} Remark, see Hesselink for a variant rule more like Cohen's. The given rule works for nontotal commands, and has a simple annotation. Pf: (use the recursion theorem). Q: so what would the annotation rule look like? Thm 30 is partial correctness and necessity for loops. Thm: The repitition L is total if and only if (!b;c) is total. (Proof is a calculation showing that wp.L.false equiv false by mutual implication.)