Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computability Turing machines for functions. Recursive functions. Homework: Modify class example for addition to produce contiguous 1s. Construct TM for.

Similar presentations


Presentation on theme: "Computability Turing machines for functions. Recursive functions. Homework: Modify class example for addition to produce contiguous 1s. Construct TM for."— Presentation transcript:

1 Computability Turing machines for functions. Recursive functions. Homework: Modify class example for addition to produce contiguous 1s. Construct TM for multiplication. If we don't finish in class: show multiplication is recursive and show proper subtraction is recursive.

2 Turing machine for functions Up until now, our TM had input a string and either accepted or rejected or did not halt. A variation of TM is to have TM compute functions (stick to natural numbers to natural numbers) – input be representation of a natural number (0, 1, 2, …): 1 stands for 0, 11 stands for 1, (n+1) 1s stand for n. – When TM stops, the number of 1s on the tape is the answer. No 1s represents 0, n 1s represent n.

3 Generalization Functions on vectors to vectors F(n, m) → (v, w, z) Use blanks in-between or use a special symbol, such as comma or $.

4 Examples F(n) = n Job of TM is to erase one 1. S0 reading a 1, writes a blank, and changes to S1, which is a final state. No more action. F(n) = 1 Job is to erase all but one 1. S0 reading a 1, moves right, changes to S1. S1 reads a 1, writes a blank, moves right. S1 reading a blank, changes to S2, a final state.

5 Examples F(n,m) = n+m. Assume representation has blank in-between two inputs. Job is to erase two 1s from initial representation. S0 read 1, write a blank, go right, change to S1. S1 read 1, go right. S1 read blank, change to S2, go right. S2 read 1, write a blank, change to S3. S3 final. NOTE: an improved version would be to make the answer be 1 contiguous string of 1s, starting at the left hand end of the tape. HOMEWORK!

6 Switch: Recursive functions [More] mathematical type of definition. The recursive functions are a set of functions defined using a starter set and allowing any functions that can be defined using a finite number of applications of composition, primitive recursion, and minimalization (will define the last two)

7 Starter set Identity F(x) = x This is special case of Projections U i n (x 1, x 2,…,x n ) = x i Successor S(x) = x+1 Constant F c (x) = c

8 Composition Given F and G, FG (x) = F(G(x))

9 Primitive recursion Motivation similar to mathematical induction, definition of factorial, exponentiation. – Have definition for the zero case. Have way for building. x 0 = 1 x (n+1) = x n * x

10 Primitive recursion Given functions f: N → N and g: (N,N,N) →N, then define h: (N,N) as follows h(x,0) = f(x) h(x,y+1) = g(x,y,h(x,y)) You will see variations. For example, f: N n and g: N n+2

11 Addition Want h(x,y) = x+y. Can we do this using primitive recursion, that is, are there some simpler functions Let f(x) = x. Then h(x,0) = f(x) = x = x+0 okay! Working backwards, I need to define g so that h(x,y+1) = x+y+1 and h(x,y+1) = g(x,y,h(x,y)). Let g(x,y,z) = S(P 3 3 (x,y,z))

12 Classwork Do multiplication!

13 Minimalization Also think of it as inverse. If f(x) is recursive, then define g to be g(y) = min {x | f(x) = y} if any x exists. Otherwise, g(y) is undefined.

14 Total versus partial A function is total if it is defined for all its domain (in this case, the counting or natural numbers). A function is partial if it is defined for some, possibly all, of its domain.

15 Classwork/Homework Define (proper) subtraction, if x >= y, then B(x,y) = x-y. If x < y, then B(x,y) undefined. Show B(x,y) is recursive. Hint: two-steps: define P(x) = x-1 if x>0, undefined otherwise. Show P(x) is recursive (using minimalization). THEN use P(x) to define B(x,y).

16 Definition The recursive functions are all functions that can be defined starting with the starter set and using a finite number of applications of composition, primitive recursion and minimalization. A recursive function is total if it is defined for all of N.

17 Claim All functions implemented by Turing machines are recursive. – Harder direction. Use Godel numbering. Will not give complete proof. All recursive functions can be implemented by a Turing machine. – Easier direction. Build TM for starter sets. Need a fix-up function to get things in proper format for next step. Describe process for doing composition, primitive recursion, and minimalization.


Download ppt "Computability Turing machines for functions. Recursive functions. Homework: Modify class example for addition to produce contiguous 1s. Construct TM for."

Similar presentations


Ads by Google