NOTE: This transcription was contributed by Martin P.M. van der Burgt, who has devised a process for producing transcripts automatically. Although its markup is incomplete, we believe it serves a useful purpose by virtue of its searchability and its accessibility to text-reading software. It will be replaced by a fully marked-up version when time permits. —HR
A small note on the additive composition of variant functions.
This is only a small note, for its observation is nearly trivial. The note is made, however, because it describes a method of some generality, by which results can be derived that —as I have observed— tend to strike the reader as “a trick” if he has never seen the like and is unaware of the method behind it.
It deals with finding a variant function for a repetitive construct with more than one alternative:
do B1 → S1 ▯ ... ▯ Bn → Sn od . |
t = t1 + ... + tn , |
We shall illustrate it with an example of matching simplicity. On a shunting yard are a finite number of trains; a train is either atomic (iff it consists of a single car) or composite (if? it consists of a finite number of cars greater than one). The yard is empty, when it contains no trains. Repeatedly we select a train: if it is atomic, it is removed from the yard, if it is composite, it is split into two (shorter) trains that, in this move, remain on the yard. The process terminates, when the yard is empty. The point is to construct the decreasing function t that is bounded from below, so that termination is proved. We sketch the process by
do atomic train selected → remove it | ||
▯ composite train selected → split it | ||
od |
t1 = CARS |
TRAINS = the number of trains on the yard , | ||
t2 = - TRAINS |
t2 = f(CARS) - TRAINS . |
t2 = CARS - TRAINS |
t2 = CLOSCONNS |
* *
*
x, y := X, Y; do X > y → x:=x - y ▯ y > x → x, y == y, x od |
* *
*
Note. Obviously the condition that ti is left unchanged by the j-th (j ≠ i) guarded commands is stronger than necessary: it suffices to establish that ti is not increased by the other guarded commands. (End of note.)
Note. Instead of choosing t = t1 + ... + tn , we could also take —after having chosen the ti — t = a1*t1 + ... + an*tn with all ai’s positive; in other words, the variant function is by no means unique, and we can choose the most convenient one. (End of note.)
The above has been prompted by my impression that some people seem to think that that there is something mysterious about the termination of the type of programs discussed. Its moral is that there is no mystery.
Plataanstraat 5 | prof.dr.Edsger W.Dijkstra |
NUENEN NL-4565 | Burroughs Research Follow |
The Netherlands |
Transcribed by Martin P.M. van der Burgt
Last revision 2014-12-08
.