170 likes | 185 Views
This text provides an overview of Turing machines that compute functions, focusing on recursive functions and examples for addition, multiplication, and proper subtraction. The text also explores the concepts of composition, primitive recursion, and minimalization.
E N D
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.
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.
Generalization • Functions on vectors to vectorsF(n, m) → (v, w, z) • Use blanks in-between or use a special symbol, such as comma or $.
Examples • F(n) = nJob 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) = 1Job 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.
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!
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)
Starter set • Identity F(x) = x This is special case ofProjections Uin(x1, x2,…,xn) = xi • Successor S(x) = x+1 • Constant Fc(x) = c
Composition • Given F and G, FG (x) = F(G(x))
Primitive recursion • Motivation similar to mathematical induction, definition of factorial, exponentiation. • Have definition for the zero case. Have way for building. • x0 = 1x(n+1) = xn * x
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: Nn and g: Nn+2
Addition • Want h(x,y) = x+y. Can we do this using primitive recursion, that is, are there some simpler functionsLet 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(P33(x,y,z))
Classwork • Do multiplication!
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.
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.
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).
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.
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.