EWD249 - 8
On our mental aids.
In the previous section we have stated that the programmer's duty is to make his product "usefully structured" and we mentioned the program structure in connection with a convincing demonstration of the correctness of the program.
But how do we convince? And how do we convince ourselves? What are the typical patterns of thought enabling ourselves to understand? It is to a broad survey of such questions that the current section is devoted. It is written with my sincerest apologies to the professional psychologist, because it will be amateurishly superficial. Yet I hope (and trust) that it will be sufficient to give us a yardstick by which to measure the usefulness of a proposed structuring.
Among the mental aids available to understand a program (or a proof of its correctness) there are three that I should like to mention explicitly:
1) Enumeration
2) Mathematical induction
3) Abstraction.
On enumeration.
I regard as an appeal to enumeration the effort to verify a property of the computations that can be evoked by an enumerated set of statements performed in sequence, including conditional clauses distinguishing between two or more cases. Let me give a simple example of what I call "enumerative reasoning".
It is asked to establish that the successive execution of the following two statements
"dd:= dd / 2;
if dd ≤ r do r:= r - dd"
operating on the variables "r" and "dd" leaves the relations
0 ≤ r < dd (1)
invariant. One just "follows" the little piece of program assuming that (1) is satisfied to start with. After the execution of the first statement, which halves