Docsity

Turing machine computability Lecture Note, Summaries of Complexity Theory

Toggle sidebar
bg1
MicroLink Information Technology College
Introduction to Complexity Theory Page 1
Chapter Two
Computability
Preliminary
A function is said to be computable if it can be solved algorithmically. We consider functions
defined on NU{0} = N
Let f: Nm → Nn
i. f is said to be total if the domain is the entire Nm
ii. f is said to be partial if the domain is a subset of Nm
Example:
a) f(x) = x2 - 4 over N
Not defined for all natural numbers N
b) f(x) = x+1 over N
It is defined for all natural numbers so it is total
c) f(x) = x/2 over N
It is defined for all natural numbers divisible by 2
d) f(x) = x2 over N
It is defined for all natural numbers so it is total
Let f be function which is computable, then
If q0w |▬* f f (w), (f ε F), then f is TM computable
Example
Design a TM that adds two positive integers.
Solution:
Let f: N2→ N be given by f (n1, n2) = n1 + n2
1) Represent n1 and n2 using unary notation, say using 1s
n1 = 1111……1
n2 = 111……..1
E.g. 5 = 11111
3 = 111
2) Separate the two numbers by another symbol, say x.
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Turing machine computability Lecture Note and more Summaries Complexity Theory in PDF only on Docsity!

Chapter Two

Computability

Preliminary

 A function is said to be computable if it can be solved algorithmically. We consider functions defined on NU{0} = N Let f: Nm^ → Nn i. f is said to be total if the domain is the entire Nm ii. f is said to be partial if the domain is a subset of Nm Example: a) f(x) = x^2 - 4 over N Not defined for all natural numbers N b) f(x) = x+1 over N It is defined for all natural numbers so it is total c) f(x) = x/2 over N It is defined for all natural numbers divisible by 2 d) f(x) = x^2 over N It is defined for all natural numbers so it is total Let f be function which is computable, then

If q 0 w |▬* f f (w), (f ε F), then f is TM computable

Example Design a TM that adds two positive integers. Solution: Let f: N^2 → N be given by f (n 1 , n 2 ) = n 1 + n 2

  1. Represent n 1 and n 2 using unary notation, say using 1s n 1 = 1111…… n 2 = 111…….. 1 E.g. 5 = 11111 3 = 111
  2. Separate the two numbers by another symbol, say x.

Initial configuration

  1. Remove x and put all the 1s together  TM Search right for x, when found replaces it by 1.  TM Search for the right most 1 and replace it by B. →Rx1RBLB

Primitive Functions

1) Zero function (Z) [zeta] Z: NM^ → Nn^ is defined by Z (x) = 0 E.g. Z (1) = 0 Z (1 , 2) = ( 0 , 0 ) Z (10 , 0 , 100) = (0 , 0 , 0) Hence Z is a computable function

2) Successor function ( σ) [sigma]

ζ: Nm^ → Nn^ is given by

ζ (x) = x + 1

E.g. ζ (0) = 1

Hence ζ is a computable function

3) Projection function () [pie] nm : NM^ → N is given by nm (x 1 , x 2 , x 3 ……..xm…………xn) = xm E.g. ^32 (1 , 0 , 2) = 0 ^41 (10 , 1 , 3 , 2) = 10  11 (2) = 2 Hence  is a computable function

B 1 1 1 …… 1 x 1 1 …. 1 B n 1 n 2

Definition: A primitive recursion function is a function that is an initial function or obtained from the initial function by a sequence of operations combinations, composition or primitive recursion. Example

  1. Let plus N^2 → N be given by plus(x, y) = (x + y) Show that plus is primitive recursion Solution: plus (x, 0) = x = ^21 (x, 0) plus (x,y+1) = x + y + 1 = (x + y) +

= ζ o plus (x,y )

= h (x , y , plus (x,y))

= ζ o ^33 (x , y , plus (x,y))

Hence, plus (x,0) = ^21 (x,0) = g(x)

plus (x,y+1) = ζ o ^33 (x , y , plus (x,y)) = h(x , y , plus(x,y))

Hence plus is primitive recursion E.g. plus (2,3) = 5 plus (2,0) = ^21 (2,0) = 2 plus (2,2+1) = plus (2,3) = h (2,2, plus (2,2)) → plus (2,2) = plus (2,1+1)=h(2,1, plus (2,1) ) → plus (2,1) = Plus (2,0+1)=h(2,0, plus (2,0) ) → plus (2,0) = 2 (given above)

Then h (2,1, plus (2,0)) = ζ o ^33 (2,0,2) = ζ o 2 = 3

h (2,2, plus (2,1)) = ζ o ^33 (2,2,3) = ζ o 3 = 4

h (2,3, plus (2,2)) = ζ o  33 (2,3,4) = ζ o 4 = 5

OR

plus (2,3) = ζ o  33 (2,2,plus (2,2))

= ζ o (plus 2,2)

= ζ o ζ o (^33 (plus (2,1))

= ζ o ζ o plus (2,1)

= ζ o ζ o ζ o ^33 (plus (2,0)

= ζ o ζ o ζ o plus (2,0)

= ζ o ζ o ζ o (2)

  1. let K be a constant function Knm: Nn^ → NK^ is given by Knm(x) = m Show that K is a primitive function Solution: K^20 (x 1 , x 2 ) = 0 K^43 (x 1 , x 2 , x 3 , x 4 ) = 3 K^30 = 0 Kn 0 (x 1 ,x 2 , x 3 ,x 4 ………xn) = 0 = (x 1 ,x 2 , x 3 ,x 4 ………xn)

Kn 1 (x 1 ,x 2 , x 3 ,x 4 ………Xn) = 1 = ζ o Z

Kn 2 (x 1 ,x 2 , x 3 ,x 4 ………Xn) = 2 = ζ o ζ o Z

(It Continue...)

Knm (x 1 ,x 2 , x 3 ,x 4 ………xn) = m = ζ o ζ o....................ζ o Z (x) = m

Hence, Knm is primitive recursive

  1. Let multi: N^2 → N is given by multi (x, y) = xy Show that multi is primitive recursive Solution: mult (x,0) = 0 = K^20 (x,0) mult (x,y+1) = x(y+1) = xy + x = plus (xy,x) mult (x,y+1) = h(x,y,mult (x,y)) = plus (^3 1, ^33 )(x,y,mult(x,y)) = plus (x,mult (x,y)) = x + xy Hence multi is primitive recursive

m

Minimalization Techniques

Let g: Nn+1^ → N be a computable function Let f: Nn^ → N be constructed from g as follows f(x) = min {y | g (x,y) is true}

= μ y [g (x,y) = a]

The minimalization technique produces a partial function. Suppose g: N^2 → N by g (x,y) = plus (x,y) By minimalization : f: N → N is given by

f(x) = μ y [g(x,y) = 0]

f(0) = g(0,y) = 0 ( i.e 0+y = 0, y = 0 ) f(1) = undefined f(2) = undefined 0, if x = 0 Undefined, for x> Supose g: N^2 → N by g(x,y) = monus (x,y) By minimalization f: N → N by

f(x) = μ y [monus (x,y) = 0]

f(0) = 0 f(1) = 1 (It Continue…) f(x) = x Definition: A partial primitive recursive is either an initial function or obtained from the initial by operations of combination, composition, primitive recursion or minimalization.

f(x) =

Turing Computable Functions

Let f: Nm^ → Nn^ be a function f(x 1 ,x 2 , ………… xm) = (y 1 ,y 2 , ………… yn) To representation (x 1 ,x 2 , ………… xm) on TM’s tape: Bx 1 Bx 2 Bx 3 B…………………..BxmB (x,y,z) = BxByBzB = B x B y B z B f(x,y,z) = (v 1 ,v 2 ,v 3 ) BxByBzB |▬* Bv 1 Bv 2 Bv 3 B We say f is Turing computable if there exist a TM such that the following holds: If f(x 1 ,x 2 , ………… xm) = (y 1 ,y 2 , ………… yn) then TM’s halting configuration Bx 1 Bx 2 Bx 3 B……….BxmB |▬* By 1 By 2 B……….BynB Theorem Every partial primitive recursive function is Turing computable. Proof: 1- Initial function i. Z: N → N is defined by Z(x) = 0

Find a TM that computes Z: Solution: Bx B |▬* B0 B is done by →LOR

ii. ζ: N → N

Find a TM that computes ζ:

Solution:

Represent n by unary notation n = 111111111 ……… 11 B

B111111111…….. 1 B |▬ B111111111…….. 1 B n^ n + 1

n

iii. Primitive Recursion Let f(x,0) = g(x) f(x,y+1) = h(x,y,f(x,y)) Let g and h be partial computable function such that M 1 and M 2 compute g and h respectively WTS f is computable f is Turing computable, Э a TM M 3 that proceeds as follows a) If the last argument of f is 0, then M 3 simulates M 1 and halts. b) If the last argument is non-zero: f(x, y+1). Then arrange the input as follows BxByBxBy-1BxBy-2B……….BxB1BxB0BxB and simulate M 1 The result is BxByB……….BxBOBg(x)B which is equivalent to BxByB……… B xB0Bf(x,0)B c) Put the head as indicated above and simulate M 2 Result: BxByB……….. BxB1Bh(x, 0, f(x, 0))B Equivalent to BxByB…………… B xB1Bf(x, 1) d) Put the head as indicated above and simulates M 2 Result: BxByB…………..BxB2Bh(x, 1, f(x, 1))B Equivalent to BxByB……….… B xB2Bf(x, 2)B e) Repeat the above process to the remaining part of the tape and simulate M 2 until the tape content contains BxByBf(x, y) Equivalent to h(x, y, f(x, y)) → f(x, y+1) Hence, f is Computable iv. Minimalization Let g be a partial computable function that is computed by TM M 1

Let f(x) = μ y [g(x, y) = 0]

WTS f is computable Let M 2 be a TM that is compute f: Construction: M 2 has 3 Tape Tape1: Contains the input x Tape2: Contains the value of ys starting from 0 Tape3: Simulate M 1

Step1: M 2 initializes Tape 2 with 0 Step2: M 2 copies x onto Tape 3 followed by content of Tape 2. Step3: Simulate M 1 on Tape 3. If the result is 0 then done, else erase Tape 3, increment the content of Tape 2 by 1, start from step 2 above. Thus Minimalization is Computable

Universal Turing Machine (Mu)

Definition: Universal Turing Machine (Mu) is a machine that given an input the description of any TM M, can simulate M on W. Construction of Mu We encode the TM M using the following:

  1. M=(Q, , r, δ, q 0 , B, F) where Q = {q 1 , q 2 , q 3 …qn}  = {0, 1} r = {0, 1, B} q 0 = q 1 F = {q 2 }
  2. Let x 1 ,x 2 and x 3 represent 0,1,B respectively
  3. Let L and R represented by D 1 ,D 2 respectively
  4. δ( qi , xj ) = ( qk , x 1 , Dm ) is represented by: 0 i 10 j 10 k 10 lL0m……… () where 1 is separator A TM can be encoded by: 11 Code 1 11 Code 2 11 Code 3 11……..11 Code n 11……………() Where each code i is of the form () Such encoding (**) is represented by f (m)