27.04.2015 Views

Computability and Logic

Computability and Logic

Computability and Logic

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.

58 ABACUS COMPUTABILITY<br />

Three different processes for defining new functions from old can be used to exp<strong>and</strong><br />

our initial list of examples. A first process is composition, also called substitution.<br />

Suppose we have two 3-place functions g 1 <strong>and</strong> g 2 , <strong>and</strong> a 2-place function f . The<br />

function h obtained from them by composition is the 3-place function given by<br />

h(x 1 , x 2 , x 3 ) = f (g 1 (x 1 , x 2 , x 3 ), g 2 (x 1 , x 2 , x 3 )).<br />

Suppose g 1 <strong>and</strong> g 2 <strong>and</strong> f are abacus computable according to our specifications, <strong>and</strong><br />

we are given programs for them.<br />

↓ ↓ ↓<br />

f ([1], [2]) → 3 g 1 ([1], [2], [3]) → 4 g 2 ([1], [2], [3]) → 4<br />

↓ ↓ ↓<br />

We want to find a program for h, to show it is abacus computable:<br />

↓<br />

h([1], [2], [3]) → 4 .<br />

↓<br />

The thing is perfectly straightforward: It is a matter of shuttling the results of<br />

subcomputations around so as to be in the right boxes at the right times.<br />

First, we identify five registers, none of which are used in any of the given programs.<br />

Let us call these registers p 1 , p 2 , q 1 , q 2 , <strong>and</strong> q 3 . They will be used for temporary<br />

storage. In the single program which we want to construct, the 3 arguments are stored<br />

initially in boxes 1, 2, <strong>and</strong> 3; all other boxes are empty initially; <strong>and</strong> at the end, we<br />

want the n arguments back in boxes 1, 2, 3, <strong>and</strong> want the value f (g 1 ([1], [2], [3]),<br />

g 2 ([1], [2], [3])) in box number 4. To arrange that, all we need are the three given<br />

programs, plus the program of Example 5.2 for emptying one box into another.<br />

We simply compute g 1 ([1], [2], [3]) <strong>and</strong> store the result in box p 1 (which figures<br />

in none of the given programs, remember); then compute g 2 ([1], [2], [3]) <strong>and</strong> store<br />

the result in box p 2 ; then store the arguments in boxes 1, 2, <strong>and</strong> 3 in boxes q 1 , q 2 ,<br />

<strong>and</strong> q 3 , emptying boxes 1 through 4; then get the results of the computations of g 1<br />

<strong>and</strong> g 2 out of boxes p 1 <strong>and</strong> p 2 where they have been stored, emptying them into<br />

boxes 1 <strong>and</strong> 2; then compute f ([1], [2]) = f [g 1 (original arguments), g 2 (original<br />

arguments)], getting the result in box 3; <strong>and</strong> finally, tidy up, moving the overall result<br />

of the computation from box 3 to box 4, emptying box 3 in the process, <strong>and</strong> refilling<br />

boxes 1 through 3 with the original arguments of the overall computation, which were<br />

stored in boxes q 1 , q 2 , <strong>and</strong> q 3 . Now everything is as it should be. The structure of the<br />

flow chart is shown in Figure 5-15.<br />

Another process, called (primitive) recursion, is what is involved in defining multiplication<br />

as repeated addition, exponentiation as repeated multiplication, <strong>and</strong> so on.<br />

Suppose we have a 1-place functions f <strong>and</strong> a 3-place function g. The function h<br />

obtained from them by (primitive) recursion is the 2-place function h given by<br />

h(x, 0) = f (x)<br />

h(x, y + 1) = g(x, y, h(x, y)).

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

Saved successfully!

Ooh no, something went wrong!