Content deleted Content added
m →While loop: \text |
m →Goto statement: {{mono}} {{tmath}} |
||
Line 153:
=== Goto statement ===
Formalization of jump statements like ''{{mono|goto}} L'' takes a very long bumpy process. A common belief seems to indicate the goto statement could only be argued operationally. This is probably due to a failure to recognize that ''{{mono|goto}} L'' is actually miraculous (i.e. non-strict) and does not follow Dijkstra's coined Law of Miracle Excluded, as stood in itself. But it enjoys an extremely simple operational view from the weakest precondition perspective, which was unexpected. We define
{| style="background-color:#eeeeff;" border="1" cellpadding="10"
|<math>wp(\texttt{goto}\ L, R) = wpL</math>
where ''wpL'' is the weakest precondition at label ''L''.
|}
For ''{{mono|goto}} L'' execution transfers control to label ''L'' at which the weakest precondition has to hold.
The way that ''wpL'' is referred to in the rule should not be taken as a big surprise. It is just
wp(do x > 0 → L: x := x-1 od; if x < 0 → x := -x; goto L ⫿ x ≥ 0 → skip fi, post)
= { sequential composition and alternation rules }
wp(do x > 0 → L: x := x-1 od, (x<0 ∧ wp(x := -x; goto L, post)) ∨ (x ≥ 0 ∧ post)
Line 179 ⟶ 180:
post(x ← 0)
Therefore,
wp(S, post == Other predicate transformers ==
|