Gödel, Escher, Bach An Eternal Golden Braid by Douglas R. Hofstadter

(Dana P.) #1

example of a full BlooP program would be the definition of the procedure
TWO-TO-THE-THREE-TO-THE, followed by the call


TWO-TO-TH E-TH REE-TO-TH E [2]

which would yield an answer of 512.
If you have only a chain of procedure definitions, then nothing ever
gets executed; they are all just waiting for some call, with specific numerical
values, to set them in motion. It is like a meat grinder waiting for some
meat to grind-or rather, a chain of meat grinders all linked together, each
of which is fed from earlier ones ... In the case of meat grinders, the image
is perhaps not so savory; however, in the case of BlooP programs, such a
construct is quite important, and we will call it a "call-less program". This
notion is illustrated in Figure 72.
Now BlooP is our language for defining predictably terminating
calculations. The standard name for functions which are BlooP-computable
is primitive recursive functions; and the standard name for properties
which can be detected by BlooP-tests is primitive recursive predicates.
Thus, the function 2311 is a primitive recursive function; and the state-
ment "n is a prime number" is a primitive recursive predicate.
It is clear intuitively that the Goldbach property is primitive recursive,
and to make that quite explicit, here is a procedure definition in BlooP,
showing how to test for its presence or absence:


DEFINE PROCEDURE "GOLDBACH?" [N]:
BLOCK 0: BEGIN
CELL( 0) ¢: 2;
LOOP AT MOST N TIMES:
BLOCK t: BEGIN
IF {PRIME? [CELL(O)]
AND PRIME? [MINUS [N,CELL(O)]]},
THEN:
BLOCK 2: BEGIN
OUTPUT ¢: YES;
QUIT BLOCK 0;
BLOCK 2: END
CELL(O) ¢: CELL(O) + t;
BLOCK t: END;
BLOCK 0: END.

As usual, we assume NO until proven YES, and we do a brute force search
among pairs of numbers which sum up to N. If both are prime, we quit the
outermost block; otherwise we just go back and try again, until all pos-
sibilities are exhausted.
(Warning: The fact that the Goldbach property is primitive recursive
does not make ~he question "Do all numbers have the Goldbach property?"
a simple question-far from itt)

(^414) BlooP and FlooP and GlooP

Free download pdf