computability turing machines for functions. recursive functions. homework: modify class example for...

17
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.

Upload: tyrone-doyle

Post on 27-Dec-2015

216 views

Category:

Documents


4 download

TRANSCRIPT

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

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.

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

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.

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

Generalization

• Functions on vectors to vectorsF(n, m) → (v, w, z)

• Use blanks in-between or use a special symbol, such as comma or $.

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

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.

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

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!

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

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)

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

Starter set

• Identity F(x) = x This is special case ofProjections Ui

n(x1, x2,…,xn) = xi

• Successor S(x) = x+1• Constant Fc(x) = c

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

Composition

• Given F and G, FG (x) = F(G(x))

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

Primitive recursion

• Motivation similar to mathematical induction, definition of factorial, exponentiation.– Have definition for the zero case. Have way for

building.• x0 = 1

x(n+1) = xn * x

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

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

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

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 thath(x,y+1) = x+y+1 and h(x,y+1) = g(x,y,h(x,y)). Let g(x,y,z) = S(P3

3(x,y,z))

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

Classwork

• Do multiplication!

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

Minimalization

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

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

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.

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

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).

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

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.

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

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.