16.05.2014 Views

C:\Documents and Settings\dave\Desktop\Godel, Escher, Bach ...

C:\Documents and Settings\dave\Desktop\Godel, Escher, Bach ...

C:\Documents and Settings\dave\Desktop\Godel, Escher, Bach ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

example of a full B1ooP program would be the definition of the procedure TWO-TO-<br />

THE-THREE-TO-THE, followed by the call<br />

TWO-TO-THE-THREE-TO-THE [2]<br />

which would yield an answer of 512.<br />

If you have only a chain of procedure definitions, then nothing ever gets executed;<br />

they are all just waiting for some call, with specific numerical values, to set them in<br />

motion. It is like a meat grinder waiting for some meat to grind-or rather, a chain of meat<br />

grinders all linked together, each of which is fed from earlier ones ... In the case of meat<br />

grinders, the image is perhaps not so savory; however, in the case of BlooP programs,<br />

such a construct is quite important, <strong>and</strong> we will call it a "call-less program". This notion<br />

is illustrated in Figure 72.<br />

Now B1ooP is our language for defining predictably terminating calculations. The<br />

st<strong>and</strong>ard name for functions which are B1ooP-computable is primitive recursive<br />

functions; <strong>and</strong> the st<strong>and</strong>ard name for properties which can be detected by B1ooP-tests is<br />

primitive recursive predicates. Thus, the function 2 3n is a primitive recursive function;<br />

<strong>and</strong> the statement "n is a prime number" is a primitive recursive predicate.<br />

It is clear intuitively that the Goldbach property is primitive recursive, <strong>and</strong> to<br />

make that quite explicit, here is a procedure definition in BlooP, showing how to test for<br />

its presence or absence:<br />

DEFINE PROCEDURE "GOLDBACH?" [N]:<br />

BLOCK 0: BEGIN<br />

CELL(0) 2;<br />

LOOP AT MOST N TIMES:<br />

BLOCK 1: BEGIN<br />

IF {PRIME? [CELL(O)]<br />

AND PRIME? [MINUS [N,CELL(0)]]},<br />

THEN:<br />

BLOCK 2: BEGIN<br />

OUTPUT,# YES;<br />

QUIT BLOCK 0-,<br />

BLOCK 2: END<br />

CELL(0)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!