Вы находитесь на странице: 1из 30

Recursive functions and their Turing-computability

Abhijit P. Pai

29th November, 2007

Outline

Computability notions Primitive Recursive Functions Recursive Functions Recursive Functions are Turing-Computable

Computability

Church-Turing thesis states that Turing Machines form a bound on what can be computed. The computational equivalence of the following have been shown:
Turing Machines Recursive functions Post systems Type 0 Grammars Calculus

Terms

Function: A function from I k to I for some k 0; (called a N N k-place function). Primitive Recursive function: Class of functions dened by 3 types of initial functions and two combining rules.

Initial Functions

The 0-place zero function from I 0 to I such that () = 0 N N Let k 1 and 1 i k. The i th k-place projection function ik fom I k toIN such that ik (n1 , ..., nk ) = ni for any N n1 , ..., nk IN The successor function from I to I such that N N (n) = n + 1 for each n I N An initial function is , , or one of the ik

Notation

n represents the sequence n1 , ..., nk where k 0 n will also be used to represent the k-tuple (n1 , ..., nk )

Combining Rules - Composition

Let l > 0 and k 0 Let g be an l-place function Let h1 , ...hl be k-place functions Let f be the k-place function such that for every n I k , N f (n) = g (h1 (n), ..., hl (n)) Then f is said to be obtained from g , h1 , ...hl by composition

Combining Rules - Primitive Recursion

Let k 0, g be a k-place function, h be a (k+2)-place function. Let f be the (k+1)-place function such that for every n IN k , f (n, 0) = g (n) and for every n I k and m I , N N f (n, m + 1) = h(n, m, f (n, m)) Then f is said to be obtained from g and h by primitive recursion

Primitive Recursive Functions

A function is primitive recursive if it is an initial function or can be generated from the intial functions by some sequence of composition and primitive recursion.

Examples

Constant functions
0 0 k = 0 : K0 is , Kj+1 () = (Kj0 ()) for each j 0 k+1 k > 0 : Kj (n, 0) = Kjk (n) k+2 k > 0 : Kjk+1 (n, m + 1) = k+2 (n, m, Kjk+1 (n, m))

Examples

plus(a, m) = a + m
1 plus(a, 0) = 1 (a) 3 plus(a, m + 1) = h(m, n, plus(a, m)), h = 3

mult(a, m) = a m
1 mult(a, 0) = K0 3 3 mult(a, m + 1) = h(m, n, mult(a, m)), h = plus(1 , 3 )

Why primitive recursive functions couldnt possibly dene computability

Each primitive recursive function has a nite encoding Generate a list of all possible primitive recursive functions in lexicographic order A1 , A2 , A3 , ... Let fi be the p.r.f. dened by Ai Consider the 1-place function f such that for every n I , f (n) = fn (n, ..., n) + 1 N f is computable. But f must be fi for some i. When evaluated with argument i, f and fi dier by 1.

Unbounded Minimization

Let k 0 and g be a (k+1)-place function. The unbounded minimization of g is that k-place function f N such that, for any n I k , f (n) = { The least m such that g (n, m) = 0, if such m exists f (n) = { 0 otherwise We write f (n) = m[g (n, m) = 0]

Regular Functions

A (k+1)-place function g is regular i, for every n IN k , there is an m such that g (n, m) = 0.

Recursive Functions

A function is recursive i it can be obtained from , ik , and by:


Composition Primitive Recursion Application of Unbounded minimization to regular functions

Computing Turing Machine Model

Input surrounded by blank on each side, written on leftmost squares of tape Head is initially at the blank just past the input string The TM M computes f if, for all w , if f (w ) = u, then (s, #w #) (h, #u#) M

Turing computability of Recursive functions - Some TMs


R# searches for the rst blank square to the right of the square currently scanned L# searches for the rst blank square to the left of the square currently scanned SL shifts left - #w # to w # SR shifts right - #w # to ##w # E (eraser) - #w # to #, where w can be empty B (backup) - #u#w # to #w #, u and w can be empty k-copier Ck (k 1) - #w1 #w2 #...#wk # to #w1 #w2 #...#wk #w1 #
l Ck - #w1 #w2 #...#wk # to #w1 #w2 #...#wk #w1 #w2 #...#wl #

The initial functions are Turing-computable

is computed by a TM that moves its head one square to the right and halts. Initial cong: (s, #) Final cong: (h, ##)

The initial functions are Turing-computable

ik is computed by E ki B i1 E ki - #w1 #w2 #...#wk # to #w1 #w2 #...#wi # B i1 transforms this to #wi #

The initial functions are Turing-computable

- A TM which transforms #1n #(n 0) into #1n+1 #

Composition is Turing-computable
Composition
l > 0, k 0, g an l-place function, h1 , ...hl k-place functions f, the k-place function such that for every n IN k , f (n) = g (h1 (n), ..., hl (n))

If g , h1 ...hl are Turing-computable, so is f. Let G , H1 , ..., Hl be TMs that compute g , h1 , ..., hl . The function f is computed by the TM k k k Ck H1 Ck+1 H2 ...Ck+l1 Hl GB k
k Ck H1 - #w1 #w2 #...#wk # to #w1 #w2 #...#wk #w1 #w2 #...#wk # to #w1 #w2 #...#wk #u1 # where ui = 1hi (n) k k After Ck H1 ...Ck+l1 Hl , #w1 #w2 #...#wk #u1 #u2 #...#ul #

Composition is Turing-computable

G makes this into #w1 #w2 #...#wk #v # where v will be 1f (n) B k makes this into #v #

Primitive recursion is Turing-computable

Primitive Recursion
k 0, g, a k-place function, h, a (k+2)-place function f, the (k+1)-place function s.t. for every n IN k , f (n, 0) = g (n) and for every n I k and m I , N N f (n, m + 1) = h(n, m, f (n, m))

If g and h are Turing-computable, so is f. Let G and H be TMs that compute g and h We write w for w1 #w2 #...wk

Primitive recursion is Turing-computable


Add a left end marker $ to input ($ G , H) using / 2 )k+1 $R k+1 (SR L# # The tape is now $#w #I m # Change tape to $#w #I m1 #w #I m2 #...#w #I 1 #w #I 0 #w # using steps:
Copy I m to tape 2 Copy w to tape 3 Erase tape 1 to get $# Move right twice to get $## Repeat till tape 2 becomes zero
Decrement tape 2 Copy tape 3 to tape 1 Put # in tape 1 Copy tape 2 to tape 1 Put # in tape 1

Copy tape 3 to tape 1 Put # in tape 1

Primitive recursion is Turing-computable

Now G and H compute successive values f (n, i) for i = 0, ..., m as: $#w #I m1 #w #I m2 #...#w #I 1 #w #I 0 #w # to $#w #I m1 #w #I m2 #...#w #I 1 #w #I 0 #v0 # to $#w #I m1 #w #I m2 #...#w #I 1 #v1 # to $#w #I m1 #vm1 # to $#vm # Now remove the $, and the output value is the value computed by f.

Unbounded Minimization is Turing-computable


g, regular (k+1)-place Turing-computable. If f is got from g by unbounded minimization, f is Turing-computable. Let G be the TM that computes g, we construct F that computes f, where for all n I k , f (n) = the least m such N that g (n, m) = 0. g regular m exists for every n F gets #w1 #w2 #...#wk # Change to #w1 #w2 #...#wk #I 0 # Create a copy of this. Apply G to the copy. If result is nonzero, add one more 1 at the end of the original and repeat. At some point, for #w1 #w2 #...#wk #I m #, G gives 0. Now, eliminate using B 1st k arguments and keep I m on tape.

Functions with strings as arguments


Dene a function known as the Gdel number gn(w) of the o string w as the number corresponding to the base = || + 1 encoding of the string. If = a, b, c, = 4. We x d1 = a, d2 = b, d3 = c gn( ) = 0 gn(a) = gn(d1 ) = 1 gn(ba) = gn(d2 d1 ) = 41 2 + 1 = 9 We add d0 so that numbers such as correspond to some string. Let D = ( d0 ) gn1 is a well dened function from I to D. N

Functions with strings as arguments

gn1 (0) = gn1 (1) = d1 = a gn1 (3) = d3 = c gn1 (4) = d1 d0 = ad0 gn1 (5) = d1 d1 = aa ...

References

Elements of the Theory of Computation


Harry R. Lewis Christos H. Papadimitriou

Thank You

Questions

Вам также может понравиться