1 / 80

::ICS 804:: Theory of Computation - Ibrahim Otieno - iotieno@uonbi.ac.ke +254-0722-429297

::ICS 804:: Theory of Computation - Ibrahim Otieno - iotieno@uonbi.ac.ke +254-0722-429297 SCI/ICT Building Rm. G15. Course Outline. Mathematical Preliminaries Turing Machines Recursion Theory Markov Algorithms Register Machines Regular Languages and finite-state automata

Download Presentation

::ICS 804:: Theory of Computation - Ibrahim Otieno - iotieno@uonbi.ac.ke +254-0722-429297

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ::ICS 804:: Theory of Computation - Ibrahim Otieno - iotieno@uonbi.ac.ke +254-0722-429297 SCI/ICT Building Rm. G15

  2. Course Outline • Mathematical Preliminaries • Turing Machines • Recursion Theory • Markov Algorithms • Register Machines • Regular Languages and finite-state automata • Aspects of Computability

  3. Last Week: Additional Varieties of Turing Machines • Turing Machines with One-Way-Infinite tape • Turing Machines that accept by terminal state • Multitape Turing Machines • Encoding of Turing Machines • Universal Turing Machines • Nondeterministic Turing Machines • Turing-Computability • Turing Machines and Artificial Intelligence • Turing Machines and Cognitive Science

  4. Course Outline • Mathematical Preliminaries • Turing Machines • Additional Varieties of Turing Machines • Recursion Theory • Markov Algorithms • Register Machines • Regular Languages and finite-state automata • Aspects of Computability

  5. Recursion Theory • The primitive recursive functions • The partial recursive functions • The class of partial recursive functions = class of Turing-computable functions

  6. The Primitive Recursive Functions

  7. Initial Functions • Recall function forming operations: • Unary inversion operator( f-1) – must be injective • Binary composition operator – h (n) = f°g(n) • We look at 2 other function forming operators: • Comp – generalization of binary composition • Pr – Primitive Recursion

  8. Initial Functions • The class of initial functions contains the following functions and no others: • The unary successor function succ • The k-ary constant-0 function Ck0 for k  0 k: number of arguments 0: indicates the value • The projection function pkj for each k  1 and 1  j  k k: number of arguments j: argument unto which the function projects

  9. Function composition • Given function • f: Nm N with m  1 • functions g1, g2, … gm each of which is Nk N with k  0. Then applying function composition to the m+1 functions f,g1,g2,…,gm yields a new function h: Nk N defined by h(n1,…,nk) = f(g1(n1,…,nk), g2(n1,…,nk),…,gm(n1,…,nk)) Comp[f,g1,g2,…,gm]:composition operator for function h

  10. Function composition • Result is another k-ary function • Comp[f,g1,g2,…,gm](n1,…,nk) = Comp[f,g1,g2,…,gm] (n) = f(g1(n),g2(n),…,gm(n))

  11. Illustration • The class is considered as a single, multipart computer of a k-ary number-theoretic function h = Comp[f,g1,g2,…,gm]

  12. Example j(n,m) = n3+m2+7 Comp[j,p33,p32](57849,6,8) = j(p33(57849,6,8),p32(57849,6,8)) = j(8,6) = 83 + 62 + 7 = 555

  13. Composition h = f  g = Comp[f,g] with m = k = 1 Summary Given function f: Nm N with m  1 and functions g1, g2, … gm each of which is Nk N with k  0. Then applying function composition to the m+1 functions f, g1,g2,…,gm yields a new function h: Nk N defined by h(n1,…,nk) = f(g1(n1,…,nk), g2(n1,…,nk),…,gm(n1,…,nk)) Comp[f,g1,g2,…,gm]: composition operator for function h

  14. Exercise j(n,m) = n3+m2+7 Calculate Comp[p21,p22,j](8,6) = ??? Comp[p32,p21,j,p22](8,6) = ???

  15. Exercise j(n,m) = n3+m2+7 Calculate Comp[p21,p22,j](8,6) = p21(6,555) = 6 Comp[p32,p21,j,p22](8,6) = p32(8,555,6) = 555

  16. Exercise If j(n1,n2,n3) = n1.n2+n3 • What is j(6,0,7) • What is the value of m and k in case of h = Comp[plus,j,p33] h(n1,…,nk) = f(g1(n1,…,nk), g2(n1,…,nk),…,gm(n1,…,nk)) (c) How many arguments does h have (d) What is f, g1 and g2? (e) What is h(6,0,7) h(6,1,14)

  17. Exercise If j(n1,n2,n3) = n1.n2+n3 • What is j(6,0,7) 7 • What is the value of m and k in case of h = Comp[plus,j,p33] m=2 k=3 h(n1,…,nk) = f(g1(n1,…,nk), g2(n1,…,nk),…,gm(n1,…,nk)) (c) How many arguments does h have 3 (d) What is f, g1 and g2? f=plus g1=j g2=p33 (e) What is h(6,0,7) 14 h(6,1,14) 34

  18. Primitive Recursion Plus function (recap) (i) plus(n,0) = n (ii) plus(n,m+1) = succ(plus(n,m)) plus(5,2) = plus(5,1+1) = succ(plus(5,1)) = succ(plus(5,0+1)) = succ(succ(plus(5,0)))) = succ(succ(5)) = succ(6) = 7

  19. Primitive Recursion • Definition of plus is recursive: applying plus to decreasing values (5,1) and (5,0) • Function forming operation to construct plus from the function succ • Given Function f: NkN with k  0 and function g: Nk+2N, we can form a new function h: Nk+1N defined by (i) h(n1,…,nk,0) = f(n1,…,nk) (ii) h(n1,…,nk,m+1) = g(n1,…,nk,m,h(n1,…,nk,m)) • We write Pr[f,g] for the function h formed by applying primitive recursion to given functions f and g

  20. Primitive Recursion • Given Function f: NkN with k  0 and function g: Nk+2N, we can form a new function h: Nk+1N defined by (i) h(n1,…,nk,0) = f(n1,…,nk) (ii) h(n1,…,nk,m+1) = g(n1,…,nk,m,h(n1,…,nk,m)) • We write Pr[f,g] for the function h formed by applying primitive recursion to given functions f and g or: (i) h(n,0) = f(n) (ii) h(n,m+1) = g(n,m,h(n,m))

  21. illustration • Classroom with two students • StudentA is good at computing (k+2)-ary function g • StudentB is good at computing k-ary function f • Instructor provides (k+1)-tuple <n1,…,nk,m> (i) h(n,0) = f(n) (ii) h(n,m+1) = g(n,m,h(n,m))

  22. illustration • Classroom with two students • Instructor provides (k+1)-tuple <n1,…,nk,m> • If m=0, StudentB reports the value of f right away, because that means clause (i) applies (i) h(n,0) = f(n) (ii) h(n,m+1) = g(n,m,h(n,m))

  23. illustration • Classroom with two students • Instructor provides (k+1)-tuple <n1,…,nk,m> • If m≠0, StudentB must still first compute the value of f for k-tuple <n1,…,nk> before Student A can start • This is passed on to StudentA who computes g(n1,…,nk,0,h(n1,…,nk,0)) (i) h(n,0) = f(n) (ii) h(n,m+1) = g(n,m,h(n,m))

  24. illustration (i) h(n,0) = f(n) (ii) h(n,m+1) = g(n,m,h(n,m)) • This is passed on to StudentA who computes g(n1,…,nk,0,h(n1,…,nk,0)) = h(n1,…,nk,1) • StudentA then computes the value of g(n1,…,nk,1,h(n1,…,nk,1)) • Until the 2nd argument of his function equals the one on the blackboard

  25. Definition • The class of primitive recursive functions: • An initial function is a primitive recursive function • If g1,…,gm 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 Comp[f,g1,…,gm] is a k-ary primitive recursive function • If f is a k-ary primitive recursive function and g is a (k+2)-ary primitive function for some k  0, then Pr[f,g] is a (k+1)-ary primitive recursive function • No other number-theoretic functions are primitive recursive except those listed above

  26. illustration (i) h(n,0) = f(n) (ii) h(n,m+1) = g(n,m,h(n,m)) • plus(n,0) = n • plus(n,m+1) = succ(plus(n,m)) • (i) plus(n,0) = p11(n) • (ii) plus(n,m+1) = succ(p33(n,m,plus(n,m))) = Comp[succ,p33](n,m,plus(n,m)) So plus: Pr[p11,Comp[succ,p33]]

  27. illustration (i) h(n,0) = f(n) (ii) h(n,m+1) = g(n,m,h(n,m)) (i) plus(n,0) = p11(n) (ii) plus(n,m+1) = succ(p33(n,m,plus(n,m))) = Comp[succ,p33](n,m,plus(n,m)) Classroom scenario: + teacher writes k+1 tuple on the blackboard, in this case a 2-tuple <n,m>, e.g. <5,2> + m≠0 so the calculation will include StudentA + StudentB calculates the value for 1-tuple <n> p11(5) = 5 + and passes the answer on to StudentA

  28. illustration (i) plus(n,0) = p11(n) (ii) plus(n,m+1) = succ(p33(n,m,plus(n,m))) = Comp[succ,p33](n,m,plus(n,m)) Classroom scenario: + StudentA then calculates the g-function, in this case Comp[succ,p33](5,1,plus(5,1)) ……(i) Expanding plus(5,1) = succ(p33(5,0,plus(5,0))) = succ(p33(5,0,5)) plus(5,0) = p11(5) = succ(5) = 6 Replacing in (i) Comp[succ,p33](5,1,6) = succ(6) = 7

  29. Other primitive recursive functions • Comment: every primitive recursive function is total • Multiplication and Exponentiation are primitive recursive functions • Monus(n,m) = n – m if n  m 0 otherwise • Sg(n) = 1 if n = 0 0 otherwise

  30. Partial Recursive Functions

  31. Partial recursive functions • Compared to Turing-computable functions • New definition of a class: partial recursive functions • The smallest class of number-theoretic functions containing certain basic functions and closing under certain function-forming operations (cf. class of primitive recursive functions) • Primitive recursive functions constitute an infinite class, but are effectively enumerable

  32. Partial recursive functions Theorem: there exists a computable function that is total, but not primitive recursive Proof Let f0,f1,f2,… be the enumeration of unary primitive recursive functions. Consider f* f*(n) = fn(n) + 1 • f* is unary and total • If f* is primitive recursive, it occurs in the enumeration (above) • Assume f* is fk for some k • Ask for the value of f*(k) • f*(k) = fk(k) • Substituting n for k (above) this means f*(k) = fk(k) + 1 as well • (Proof by) Contradiction!!!! • f* is computable: for any n, find the nth function in the enumerable list of primitive recursive functions, compute the value of fn and add 1 • f* is Turing-computable

  33. Number-theoretic Predicates (recap) Properties of objects, relations, holding between pairs of objects, relations, holding among triples of objects are expressed using predicates. If the objects are members of N, then one speaks of number-theoretic predicates e.g. prime(n) is a unary number-theoretic predicate that is satisfied by 2 and 3, but not by 4 or 6

  34. Least number operator • : least number operator • m[C(n,m)] the least natural number m such that predicate C(n,m) holds • m[C(n,m)] = 0: the least natural number such that f(n,m) is equal to 0

  35. Minimization • New function-forming operation, Mn suppose that f:Nk+1N with k  0 is given. We write Mn[f] for the function g:NkN defined as: g(n) = m[Cf(n,m) = 0 and such that for all j < m, f(n,j) is defined and ≠ 0

  36. Minimization e.g. f(3,0) = 7 f(3,1) = 4 f(3,2) = 4 f(3,3) = 2 f(3,4) = 9 f(3,5) = 0 f(3,6) = 4 … Then g(3) = Mn[f](3) = m[f(3,m) and such that for all j < m, f(3,j) is defined and ≠0] = 5

  37. Minimization e.g. f(3,0) = 7 f(3,1) is undefined f(3,2) = 4 f(3,3) = 2 f(3,4) = 9 f(3,5) = 0 f(3,6) = 4 … m[f(3,m)= 0] = 5 but g(3) = Mn[f](3) is undefined

  38. Minimization e.g. f(3,0) = 7 f(3,1) = 4 f(3,2) = 4 f(3,3) = 2 f(3,4) = 9 f(3,5) = 5 f(3,6) = 4 … g(3) = Mn[f](3) is undefined

  39. Exercise f(0,0) = 6 f(1,0) = 8 f(2,0) = 3 f(3,0) = 9 f(4,0) = 6 f(0,1) = 4 f(1,1) = 8 f(2,1) = 1 f(3,1) = 6 f(4,1) = 6 f(0,2) = 6 f(1,2) = 6 f(2,2) = 6 f(3,2) = 4 f(4,2) = 6 f(0,3) = 0 f(1,3) = 6 f(2,3) is undefined f(3,3) = 6 f(4,3) = 6 f(0,4) = 6 f(1,4) = 5 f(2,4) = 6 f(3,4) = 0 f(4,4) = 6 f(0,5) = 8 f(1,5) = 0 f(2,5) = 0 f(3,5) = 6 f(4,5) = 6 with f(4,m) = 6 for all m Calculate g(0) = Mn[f](0) g(1) = Mn[f](1) g(2) = Mn[f](2) g(3) = Mn[f](3) g(4) = Mn[f](4)

  40. Exercise f(0,0) = 6 f(1,0) = 8 f(2,0) = 3 f(3,0) = 9 f(4,0) = 6 f(0,1) = 4 f(1,1) = 8 f(2,1) = 1 f(3,1) = 6 f(4,1) = 6 f(0,2) = 6 f(1,2) = 6 f(2,2) = 6 f(3,2) = 4 f(4,2) = 6 f(0,3) = 0 f(1,3) = 6 f(2,3) is undefined f(3,3) = 6 f(4,3) = 6 f(0,4) = 6 f(1,4) = 5 f(2,4) = 6 f(3,4) = 0 f(4,4) = 6 f(0,5) = 8 f(1,5) = 0 f(2,5) = 0 f(3,5) = 6 f(4,5) = 6 with f(4,m) = 6 for all m Calculate g(0) = Mn[f](0) = 3 g(1) = Mn[f](1) = 5 g(2) = Mn[f](2) is undefined g(3) = Mn[f](3) = 4 g(4) = Mn[f](4) is undefined Even if f(2,3) were defined, Mn[f](n) = g(n) would still be partial

  41. Partial • The exercise shows that applying minimization operator Mn to a total function may result in a partial function

  42. Partial recursive functions defined • The class of partial recursive functions is the smallest class containing all initial functions and closed under the operations Comp, Pr, Mn • So: every primitive recursive function is also a partial recursive function • A total partial recursive function = recursive function

  43. World of number-theoretic functions Partial Recursive Functions Recursive Functions Primitive Recursive Functions

  44. The class of partial recursive functions = class of Turing-computable functions

  45. Theorems • A number-theoretic function is partial recursive if and only if it is Turing Computable • If number-theoretic function h is partial recursive, then h is Turing-computable Forward Proof (partial recursive  Turing Computable): • Initial functions • Comp functions • Pr functions • Mn functions

  46. Proof: initial functions • Successor function

  47. Proof: initial functions • Constant-k function • Erases k groups of 1s off to the right, writes a single 1 and halts • e.g. C00 B:1 0 1

  48. Proof: initial functions • Projection function. Erase all sequences of 1s on the tape, except the one that is projected unto, e.g. p32 7 B:L 2 4 1:R B:R B:R B:R 1:B 1:B B:R B:R 0 1 3 6 5 1:L B:L 1:L

  49. Proof: Comp • h = Comp[f,g1,…gm] • f is an m-ary partial recursive function • g1,…,gm are k-ary partial recursive functions • We have Turing Machines Mf,Mg,…Mm • Mcomp will simulate the composition of Turing Machines Mf,Mg,…Mm

  50. Argument nk Argument n1 Argument n2 Input tape Argument nk Argument n1 Argument n2 Worktape-1 … Argument nk Argument n1 Argument n2 Worktape-m Output tape Copy k arguments from input tape to m worktapes

More Related