0% found this document useful (0 votes)
14 views19 pages

Taylor Cap3 2

Uploaded by

Kathe Isabelle
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
14 views19 pages

Taylor Cap3 2

Uploaded by

Kathe Isabelle
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 19
Chapter D An Introduction to Recursion Theory In this chapter we introduce three important classes of number-theoretic functions and investigate their properties—in particular, their relation to the class of Turing-computable functions introduced in Chap- ter 1. Ultimately, we propose a general analysis of computation that gives prominence to the function computation paradigm. A related analysis featuring the language recognition paradigm is postponed until Chapter 12, §3.1 The Primitive Recursive Functions o + 0 The reader wil be familiar with several function-forming operations —operations that may 2 =a 1 _be applied to functions generally al to amber theoretic functions in particular, so as > 2 to yield new functions. Thus, consider the unary function ee? y Bisse ES 4 a api n+3 if nis even 5 <= 5 = = i {i 1 if nis odd which maps 0 to 3, 1 to 0, 2 to 5, 3 to 2, and so on (see Figure 3.1.1(a)). Since f is injective or 1-to-1, we can speak of its inverse f~' mapping 0 to 1, 2 to 3, 3 to 0, and a, ins Fs che reashof mency resting he aoa B.LM(@) (see 2 Pe Figure 3.1.1(b)). Note that f~" is undefined for ean I fe 3 3 Wecan think of fas the result of applying a unary inversion operation, denoted by 4 J 4 operator ~', to function f. As another example of a func ion-forming operation, consider fy 1, function composition, Thus if f and g are unary functions defined by f(n) = 3n4e2 and g(n) = n+ 1, respectively, then we define f 0 g(n) = f(g(n). In that case We © have fog = (4) = 17. Here o names a binary function-forming operation Figure 3.1.1. The applied to ewo functions f and g, yields a third function h — fg. In this section we arite tine ont fai shall have occasion to consider two other very important function-forming operations: injective so that f—' is one of which is merely a generalization of function composition as just described. defined. Let us now define a new dass of number-theoretic functions, 188 new. (i) the (unary) successor function suce; {i the F-ary constant-0 function Cf} for each k > 0: y—~28, Ch, 68, of (ii) the projection function p5 for each k > 1 and 1 1 and functions g1, 92, ...» 9m» each of which is N* —+ N’ with k > 0. Then applying function composition to the m + 1 functions f, gi, 92...» gm yields a new function h: N* — A defined by (Schema A) — Ami, ... 7) = F911... Mk)s G2(MAy «+s My os Gml(MAy-- MK) We shall write Comp[f,91, 92,---,9m] for function h here, where Comp indicates the function ‘composition operator. Note that applying Comp to an m-ary function f and m k-ary functions 1, 92+ +++» gm is another Keary function. As an additional notational simplification we shall in the future write 7 for the parameter list m,...,724. Assuming these simplifications, Schema A can now be rewritten as Compl f, 91, 92+ ++ Gm] = f(g, 924), . -- Gm(7)) In an effort to achieve a certain concreteness, we describe a classroom scenario that models Schema A. There are exactly m +1 students in the class, each of whom is equipped with pencil and paper and each. of whom is able to compute the value of a particular number-theoretic function. Expressed differently, ‘ach student knows how to calculate the value of his or her personal number-theoretic function for any given tuple consisting of an appropriate number of arguments. For convenience, we assume that the students are seated in two rows. In the front row there are 7m students, computing k-ary functions that we designate 91, g2,.--» Ji» respectively. Immediately behind them is a single student who knows how to calculate an m-ary function that we designate f (see Figure 3.1.2(a)). We describe a scenario a iittala ii 190 Models of Computation Figure 3.1.2 The class collectively computes function h Complf, 91, 9» + 9m] , ‘An Introduction to Recursion Theory 191 whereby the class as a whole computes k: : DN rics th: inatrucnoele fe eee It = Compl, 01 93.» gm). The computation eiten on pieces of paper, szy—and gives one copy vo ech a oobi OF Rete (miss. Pk) — DO etioied procaine PY to each and every one of the m students in the oe DY cis Gore can rt ae Afier sae time, when the calculations are completed, " ‘ion of a single natural number that is the value of his function for 8 t isthe ees ae ns Nk) as provided by the instructor. In other words, the OE,), thie second stud 7 Possession of a natural number that is none other than g(r RW lent will be in possession of ga(ny,...,my), and so on. Next, at one and the same time, the students in the front row communicate—on slips of paper, say-—the values of theit personal functions for arguments (n),... »M) to the single student seated behind them. That student now proceeds to compute the value of his or her personal function f for arguments gi(my,....Mx) through gmn(mi,---»Mx), in that order, as provided by the students in the front row. After a brief time, when these calculations are completed, this student is in possession of a single natural number that is none other than f(g:(m,...,7%),92(r1,-.., nk), +Gm(N),...,N)). It is convenient to assume that the student writes this number on the chalkboard, at which point the computation terminates (see Figure 3.1.2(b)) Schema A invites us to regard the entire class as a single, multipart computer of a k-ary number- theoretic function that we might designate h. The arguments (n1,...,mx) of h are provided by the instructor upon entering the classroom. The value of h for these k arguments—that is, h(n... .12x)— is found on the chalkboard at the end of the class’ calculations. Of course, calculating h(m,...,Mx) involves calculating values of functions f,91;.92,-- ms of which h is “composed.” This is reflected in an alternate name for h, namely, Comp[f, gi, 92). - +» 9m]- Summarizing, we note that if both (1) individual members of the class variously compute k-ary functions 91, 92» -+»Gm as well as m-ary function f and (2) the activities of the instructor and the students are coordinated as described earlier, then gm) whose value (3) the class collectively computes a well-defined k-ary function Complf, 91,92 for arguments (72,574) is f(g (01, ~~» ko Ga(Mir-- >» Tk->-»Gm( "ats +57). of Definition 3.2, suppose that EXAMPLE 3.1.1 As a first example of function composition in the sense Jis the binary function defined as (n,m) = n® + m2-+ 7. Thus we have j(8, 6) = 512 + 36 +7 = 556. Let us evaluate Comp|/, P3, P31(57849, 6, 8) By the definition of function composition, this is just 1(p3(67849, 6,8), p3(57849, 6,8)) re 8 and 6, respectively. So Complj, 3, p3](57849, 6, 8) has But 13(57849, 6,8) and p3(57849, 6, 8) al ; * ses, The ba should verity that Compip?, p2,/K(@,6) = 6 and that Complp3, p?./, P3118, 6) | ee 192 ‘Models of Computation : in the sense of Definition 3, Note that our preliminary example ht =at, f 09 77 ox eal : thus the general defisidon fog) = (OS) — 4 2 which is called primitive recursion, consider setm = land k= 1. E : To motivate our second function-forming OPE Ft ural numbers, where We are writing recursion equations for the binary addition funct for the successor function: @ plus(n,0) =" Gi) plus(n,m +) = suce(plus(n, ™)) _ note that we cannot apply (i) t0 the pait (5,2) since sf pe meher hand we can apply (ii) £0 the pair (5,2) if we that m is 1. Thus Using (i) and (ii) we can evaluate plus(5, (i requires that the second argument be 0. On let n be 5 and construe 2 as m +1, which means 1 plus(5,2) = plus(5,1 + 1) by2=1+1 = suce(plus(5, 1)) from (ii) = suce(plus(5,0+1)) byl=O+1 suce(suce(plus(5,0))) from (ii) = suce(succ(5)) from (i) = suce(6) by definition of suce =7 by definition of succ Note that our definition of plus is recursive in the sense that plus(5, 2) involves applying plus to smaller operands—that is, to (5,1) and to (5,0)—in turn, What we seek now is a function-forming operation that enables us to construct plus from the function suce and perhaps some other function(s) so as to achieve this effect of building up from smaller arguments. (suce is pronounced “successor,” of course) ‘One way in which we can do this is to use the function-forming operation defined as follows. DEFINITION 3.3 (Primitive Recursion): Given function f:N* > N’ with k > 0 and function g:N**? —, NV, we can form a new function h: N**! — A’ defined by (Schema B) @ (ny, ..., mk, 0) = Fim. ...nK) G) Ay,....n M+ 1) =glny,.... Mm, Alm, ....m%,M)) Neal We Prlf,g] for the function h formed by applying primitive recursion to given AAs before, we can abbreviate Schema B as ©. ria,o) = Fm (i) h(,m +1) = gt, m, h(Gi,m)) ‘An Introduction to Recursion Theory 193 ‘One should think of Pr as the name of a new function thar order, yields the new number-theoretic function ; nd 9, Py fseion 2nd 9's (E+ 2) ay nc, ten Nic nh ‘We again take a moment to describe a dassroom scenario that may help the reader to better com- prchend Schema B. This time there are only two students in the clasroom, Both are equipped with pencils and an unlimited quantity of paper. One ofthe students is adept at computing «cern ary Fimber-theoretic function f: Given any k-tuple of arguments (n,. puting forming operator that, applied to f and g, in Fi 4m), this student calculates value flnys-+-»nx)- The second student knows how to calculate the value of a cerain (k + 2)-ary function for any given (k + 2)-tuple (nj,..., 42). We show how the two students, through coordination of their calculating activities, can together compute the value of the new (k + 1)- h= for any given (K+ 1)-tuple (ri,...,n4 41). 3 Sh SS sece ae The instructor enters the classroom and writes (k +1)-tuple (ry,....74,7™) on the chalkboard. This (k + 1)-tuple remains on the chalkboard throughout the collective computation of the ewo students. ‘There are two cases to consider. # If m = 0, then, in accordance with Schema B(j), all that is required is that the first student report the value of f for k-tuple (n1,...,mx) ‘¢ Ifm £0, then the collective computation of the two students is more extended, but it still must start with the first student. Namely, to begin, this first student must compute the value of f for k-tuple (ni,-.-smg)- By Schema B(i), this value is just h(r,.--.714,0) and will now be used by the second student, who computes the value of function g for (it +2)-tuple er ee OM | tothe second student since they | -+| by theirst student. “are yet on the chalkboard. By (B)Gi), this value g(r, ---.7 0, hm,» 14,0) is h(a. -»5 ks Ds which will now be used by the second student who computes the value of function g for (k +2)-tuple (nyse M gs A(M4s ‘This value was calculated ea 0 ithe oy ae bby the second student j . cchalkbo: ‘moment ago. } This process is iterared by the second student exactly rm times, eventually resulting in the computation of Pr{f, gl(n,,....mem +1) = Aln,--m»m +1) = gry MyM, A(Nj,---»MesTA))- We pote char neither student alone computes = Pe{f,g]. It is rather the ewo srudents sgeter who, through coordination of their computati al activities as directed by Schema B(i) and (ii), compute h = Pr{f,g). (Obviously, the division of labor is not opdimal: If m # 0, then the second student does most of the work.) ive recursive) As an application of these ideas, we show that EXAMPLE 3.1.2 (Addition is primitive ree at. rimitve recursion operator o other functions. the binary addition function is the resul 194 Models of Computation ; write as Consider again the recursion equations for addition, which we pus(n.0) =" iy. plus(n,m +1) = ‘suce(plus(n, m)) rit Note that nin the right-hand side of (is just pf(n)- (Why?) So () may be neil (i) plus(n,0) = P}(n) Also plus(n, m) = p3(n, m, plus(n, m)) so that (i) is (i) plus(n, m + 1) = suco(p§(n, m, plus(n, ™)) = Comp[suce, p3](n,m, plus(n,m)) Finally, these rewritings of (i) and (ii) show that plus is none other than Prip}, Complsucc, p31} 4.4) 1 311 Apparently the addition function results from applying Pr to pj and Comp[succ, p3). We now define a very important class of number-theoretic functions called the class of primitive recursive functions, We define this class by recursion. DEFINITION 3.4: We define the class of primitive recursive functions as follows: (@ Any inicial function is a primitive recursive function, (ii) If g1,-...dm are each k-ary primitive recursive functions for some k > 0 and f is an m-ary primitive recursive function for some m > 1, then Compl f,g1,-.-. dm] is a k-ary primitive recursive function. ii) If f is an k-ary primitive recursive function and g is an (k + 2)-ary primitive function for some k > 0, then Pri fg] is a (k + 1)-ary primitive recursive function, (iv) No other number-theoretic functions are primitive recursive except those obtained from clauses (Gi) The definition cells us, in effect, that a function is primitive recursive if and only if either (1) itis among the initial functions or (2) it can be constructed from initial functions using Comp and Pr. We often express this by saying that the class of primitive recursive functions is the smallest class that contains all initial functions and that is closed under the function-forming operations Comp and Pr. in tems of suce. The usual characterization of suce as suce(n) yg m+ 1 might chen to have defined suce in terms of addition—an apparent circularity. This would be to misunders “s suce(n) =u 1+ 1. In fact, our purpose here is on ‘namely, that unary Function that takes 0 0 1, 1 to Given any natural number n, suce(n) is that unique lerstand our intention in ly appeal to the reader's understanding of what the successor 2,2 t03, and so on. That is all we mean by writing suce(n) =e ‘natural number immediately following n in the progression 0, 1, 2.3»: ‘An Introduction to Recursion Theory 195, shows that seston is primitive recursive. Por, auc att enn of acition at (9.1.1) recursive by clause Or Definition 3.4. By clause (il) of that definition, oan ener recursive. Finally, ey + Comp{succ,p3I is itself primitive recursive a ae is primitive ‘Summarizing, function plus is primitive r G intial functions and (2) the primitive recursive funtion rs cha ter eee Ite aie cre ee —— \MPLE 3.1.3 (Any constant fu k ras eS vo cone inction C/‘ is primitive recursive) As a further application of Defini- tion 3.4, all constant functions are primitive recursive. Take as an example the unary constant-t function defined by C{(n) = 1 for all n. Apparently, C}\(n) = suce(Q{(n) forall n. So G} is Comp(succ, Co |. Similarly, the unary constant-2 function C! is Comy 4, p[succ, Comp|suce, C]. It ise: enough to see that all other constant functions are Bina eaeeasiel (coo Exoreiee 37.3). We emphasize {hat itis only the constant functions that are primitive recursive by virtue of being among the initial functions. That all other constant functi clause (ji) of Definition 8.4 (closure under Comp). On Ae PERUINS Seea a We claim that every primitive recursive function is a total function. We prove this by induction on the complexity of primitive recursive functions, by which we mean the number of times we have applied operations Comp and Pr. First of all, it is obvious that all of our initial functions are total. So we need only verify that the property of being a total function is preserved under the operations Comp and Pr. Take Comp first and suppose that functions f, 91,--.+4m in Schema A are all toral. (This is our induction hypothesis.) But if f,41,.--»gm are all total, then the right-hand side of schema (A) is defined for all n,,...,m4. That is, h = Comp[f, 1, .--» 9m is defined for all m),...,r, which means that h = Comp|f, 9:,..- dm] is total. Next, we show that if functions f and g are both total, then so is Pr[f, g]. This requires induction on the natural numbers within our induction on the complexity of primitive recursive functions. First, since f is total, we have, by (i) of Schema B, that (fi, 0) is defined for all 7i. Next, assuming that h(i, m) is total (for fixed m), the right-hand side of (ii) of Schema B is toral, given that g is total. So h(i, m + 1) is total. We have proved, by so-called double induction, the following proposition. THEOREM 3.1 In fact, every total number-theoretic function that is likely to occur to you is primitive recursive. We now show that the binary multiplication function and the binary exponentiation function are both primitive recursive. In each case, we first write a pai of recursion equations, on the model of those for addition given above, for the given function. In doing so, we are free to refer to functions previously shown to be primitive recursive—for example, addition. We then begin rewriting these recursion equa tions so that they eventually conform to the definitions of function-forming operations Comp and Pr 4s given in Definitions 3.2 and 3.3, respectively. primitive recursive function is total. 196 Models of Computation sion equations EXAMPLE 3.1.4 (Multiplication is primitive recursive) We use the rect! 0) mult(n,0) = (i mutt(n,m +1) = matin, mm) +P = n+ mutt(n,™) Let us use prefix notation for the addition function, which gives @ ——_-mult(n,0) = (i) mult(n, m + 1) = plus(nn, mult(n, m) But now notice that the right-hand side of (i) is just G4 (7) 0 that ()) may be written () mutt(n,0) = 3(0) Also, note that n = p3(n, m, mult(n, m)) and that ‘mult(n, m) = p3(n,m, mult(n, m)), so that (ji) may be rewritten as (i) mutt(n, m+ 1) = plus(p3(n, m, mult(n, = Complplus, p?, p3](n, m, mult(n, m)) This means that mutt is none other than PriGj, Compiplus, pj, pl. We are permitted to name plus here since that function was previously shown to be primitive recursive; It's Just Prip} , Compisuce, p3]}. Substituting, we have that mult is PriC) , ComplPrip}, Compisuce, p3]], P?, P3ll- ‘m), p3(n, m, mult{n, m))) EXAMPLE 3.1.5 (Exponentiation is primitive recursive) Let us write exp(n, m) for n™. We then have recursion equations @ exp(n,0) = 1 (li) exp(n, m+ 1) = exp(n, m)-n =n- exp(n,m) Again, introducing prefix notation, we rewrite (|) and (ii) as 0) exp(n, 0) =1 (i) exp(n, m + 1) = mult(n, exp(n, m)) We saw in Example 3.1.3 that 1 = Cj (n) = Comp|suco, Gn) so that (i) becomes () exp(n, 0) = Compisuce, C3 \(n) An Introduction to Recursion Theory 197 so, = Bim 020(0.m) ane x(n.) = 8. exten) (booms (i) exp(n,m +1) = mult(p3(n, m, exp{n,m)),08(n, m,exptn, m)) = Comp|mutt, p?, p31(n, m, exp(n, m)) This means that exp is none other than Pr[Comy ted to use mult here since it was previously sh and pretty printing, we have that exp is ip[suce, C3], Comp|mult, p3, p3]]. Again, we are permit- » Cp}, Cor PS. Again, permit }own to be primitive recursive, Substituting that definition Pr [ Comp [ succ, q h Comp | Pr { terminates but none ever equals 0, then, in this ease also, om). our student continues computing forever without ever reporting a value for g(m1,M2,. Models of Computation of recursion theory by defining the impo; into the element cions is absolutely central t0 the class Now we continue our excursiot c of functions mentioned in Example 3.3.1. This computability. crions is the smallest class containing all ini DEFINITION 3.7: The class of partial recursive fom ats functions and closed under the operations Comp, Pry ‘The following equivalent recursive definition of the class of partial recursive functions will prove in the next section. define the class of partial recursive functions as fol 1 is, the successor function succ, the k-ary constant-0 | I projection functions pj for k > 1,1 0, as well as al all partial recursive. function with m > 1, then Comp|f, 91, Gii) If f is a k-ary partial recursive function and g is a then Pr[f, g] is partial recursive. (iv) If f is a (k + 1)-ary partial recursive function with k > 0, (¥) Nothing else is a partial recursive function. 4 gm] is partial recursive. : (k-+ 2)-ary partial recursive function with k > 0, then Ma(f] is partial recursive. ‘The foregoing discussion explains why this class is so-named. Also, it is obvious from our definition that every primitive recursive function is partial recursive. We introduce the term recursive for those partial recursive functions that happen to be total recursive function that is total is referred to simply as a recursive DEFINITION 3.8(a): Any part function Note, in connection with Definition 3.8a, thar since any characteristic function xc(M) is of neces sity total, x¥c(n)’s being partial recursive implies that xc-(n) is recursive. This reflection motivates the following terminology. DEFINITION 3.8(b): A number theoretic predicate whose characteristic function is partial recursive (and hence recursive) will be referred to as a recursive predicate. Z We note immediately that any primitive recursive predicate, as defined in Definition 3.5, is since, by Theorem 3.1, every primitive recursive function is recursive. On the other hand, Ackermann’ function is an example of a recursive function that is not primitive recursive. (Again, we have presented the required proofs.) The world of number-theoretic functions can now be pictured as im th Venn diagram of Figure 3.3.1. 7 EXAMPLE 3.3.3 It was mentioned earlier that Ackermann’s function is (partial) recursive, is hardly easy to see. For a simpler example of a partial recursive functi itive consider div(n, m), whereby integer division is intended. We note "hat ths Lncion ina div(n, m) = ntlsucc(n) ~ (t- m-+m) = 0} eae That the right-hand side here behaves as required seen, forthe case n = 19 and m=7, by consulting tage, 3.3.1. Apparently jt[succ(n)~(t-m4+m)=OJis2torthe U= ll: N*—N for some k} case n= 19 and m — 7, so that (3.3.2) pat given that 19 div 7 is indeed 2. ) appears to hold, rae Itis instructive to show that (3.3.2) can be made to con- ae for to Schema C. Let us write f(r, m,t) for the ternary Fi(nm) aa functions Value of t Value of succ(n) ~ (t: m +m) 20~(0-74+7)=13 20=(1.747)=6 20=(2-7+7)=0 20=(3-7+7)=0 20=(4:74+7)=0 £ Figure 3.3.1 primitive recursive, and hence partial recursive, function succ(n) ~ (t- m + m). Then (3.3.2) may be rewritten as div(n, m) = j.t{f(n, m, t) = 0}, so that div(n, m) is none other than Mn{f] and hence partial recursive by Definition 3.7(iv). Finally, we remind the reader that we shall frequently write infix n div m, as was already done in Exercise 3.2.4(a) and elsewhere. In what follows, we shall not take such pains ro demonstrate that a function is partial recursive but shall be satisfied to merely present an expression such as (3.3.2), whose right-hand side mentions only functions previously shown to be partial recursive as well as the 1-operator. By analogy with our method of proceeding in the case of primitive recursive functions, we shall speak of such expressions, as well as the functions defined by them, as visually ot prima facie partial recursive. Again, this is a matter of convenience, As in the case of Example 3.3.3, with a litle work we can invariably show that such function definitions are strictly in accordance with Schemata A, B, and C and are thereby partial recursive by Definition 3.7. In particular, we note that many of our arguments with respect to the primitive recursive functions and predicates carry over to the partial recursive functions and predicates. By analogy with Example 3.2.3, ifa function { is definable by cases from partial recursive functions together with mutually exclusive and exhaustive recursive predicates, then f is itself partial recursive (see Exercise 3.7.9) © By analogy with Examples 3.2.4 through 3.2.6, the class of recursive predicates is closed under the bounded universal and existential quantification (see Exercises 3.7.10 five logical connectives as well as and 3.7.11). & (a) Leting (n,m) = n? wo oe We wish to compute the value of tion h = Compl. pip for cera ‘case of this particular funct i the value of k in this case? Sy ion arguments will h have? (© What is the value of AQ3,5,38) = Complj, 73, 731(3, 5, 38)? p 31.2. "™* (@) We wish to compute the value of function h = Compiplus, p§, p§] for cer- tain arguments. Referring to Schema A of Definition 3.2, what is the value of m in the case of this particular h? What is the value of k in this case? So how many ar. guments will h have? (b) What is the value of (3,5,0,22) = Complplus, p3, p{)(3, 5,0, 22)? (© Let j(n,m) = n? + 2m + 3. We wish to compute the value of function h = Prlj, Compiplus, p4, pil). Referring to Schema B of Definition 3.3, what func. tion serves as f in that schema in the present case? What function is serving as g? What is the value of k in the case of this h? (Hint: Note that k is the “-arity” of f.) () What is 1(3,5,0)? What is h(3,5,1)2 What is h(3,5, 2)? What is h(3,5, 3)? 3.1.3. (a) If j(ni, n2,n5) = m1 - m2 +15, what is 5(6,0,7? (b) We wish to be able Comp([plus, j, 73] for various arguments. Referring to Schema A of Definition 3.2, what is the value of mm in the particular case of h = Comp|plus,j,p3]? What is the value of k in the particular case of h = Compiplus, j,p3)? So how many to compute +243, whae a4, 3.1.5. 3.1.6. 3.47. JUS wil be sel in Breese 3.1.4 ber () Again, let j(m,nz.n3) = m ~ ma + 73 as before. We wish to compute Pr[suce, Complplus, j,p3]] applied to certain small arguments. ring to Schema B of Definition 3.3 and let- ting h = Pr{succ, Comp(plus, j, Pal], what is f in the schema? What is the value of it in the particular case of h = Pr[succ, Comp{plus, j, p3]]2 What is g in the schema? What is h(6,0) = Pr{suce, Compiplus, JPA, OF (©) What is h(6, 1) = Pr{suce, Compiplus, A PMG WE () What is h(6,2) = Prlsuce, Compiplus, IrP3NG,2)2 3 Evaluate each of the following expressions. In each case your answer should be a natural number. (@) Complp3, 0}, suce(9). (b) p8(8, 45, 23,79, 1, 1) (©) Complsuce, Comp[suice, Comp|suce, Cpn]O) (d) Prip3, Complsuce, p4]](6,35, 2) Explain why Compl(p3,Cj,succ] in fact names no function. ‘hwk Evaluate each of the following expressions given in canonical notation. In each case, your answer should be a natural number. Assume ~ ) cmp 318. that mult is the usual binary muliplication function defined by mult(n,m) = 7° ™ ‘Also, assume that sums is the ternary addi- tion function on the natural numbers, that is, suma(n,m, k) = n+ m+ ke (@) Comp[suce, p](7, 14,8) (b) Comp{mult, p}, p3}(7, 14,8) (© Complsuce, Comp{mult, p>, 73)] 7,14,8) @ Prisuce, sum3](7,2) ‘We wish to see hat several other useful func- tions are primitive recursive. Fill in che blanks below so as to complete the following demon- strations that the functions in question are primitive recursive. Of course, we freely appeal to functions that have been shown previously to be primitive recursive. (a) Proposition. The function pred de- fined by is primitive recursive. Note that pred is just the ordinary (unary) predecessor func- tion except that the predecessor of 0 is now not —1 but, rather, 0 itself Proof. Function pred can be defined by @ pred(0) =0 (i) pred(m + 1) = pi(m, pred(m)) But this shows that pred is primitive re- cursive, since in the first equation 0 can be written C8(). Letting k be 0 in Schema B in Definition 3.3, we have that pred is Pr. ; in (b) Proposition. The function defined by n-m ifn>m monusionm) = { otherwise is primitive recursive. Note that monus is just like ordinary subtraction except that negative values are blocked: monus(4,7) equals 0. Ie will sometimes be convenient to write n~ m for monus(n,m). Proof. We have the following recursion equations: @ monus(n,0) =n (i) monus(n, m+ 1) = pred(monus(n,m)) sg(n) = monus(C} (n), monus(__, n)) 3.1.9. Show that the unary function f(m) =n 3.1.10. (a) Show th: 3.1.11. Show that the binary number © Proposition. ‘The (unary) is primitive recursive. Proof. Note that s9(n) = mo monus(1,n)). (Verify this for n = n = 3, say.) But everything on the here is primitive recursive. For 1 Ch(n), giving = monus(pA(C} (n), n), monus(__ my = Comp{___. ___. __l(Ci@ay = Compl. = Comp[Comp|___, ___, __], ch, primitive recursive. binary function maz (b) Show that binary function mi is primitive recursive using defi cases. tion f(r, m) =<. [m= m| is primi sive. (Hint. Use definition by cases.)

You might also like