Anda di halaman 1dari 62

Turing Machine / Counter Machine / Ackermanns function

By . Amit R Khaparde Dept : Information Technology College : NYSS College of Engineering & Research , Nagpur

Recursively enumerable and recursive language

The class of language which is accepted /recognized by Turing machine is recursively enumerable(r.e.) language/ Turing acceptable /Turing recognizable language. Turing machine
Recursive enumerable language Recursive language
Language associated with Turing machine

Amit R Khaparde

A language L over is said to be recursive enumerable, if there exists a TM that accept it.
Some time this languages are called as Turing acceptable language. i.e for all strings not in L the machine either halt in a non-final state/ goes into an infinite loop. A language L over is said to be recursive if there exists a TM that recognize it.

Amit R Khaparde

I,e for every word in L there is TM that will accept it and for every word not in L TM will reject it. L is said to be recursive if and only if there exists a membership algorithm for it. Recursive language is also called as Turing decidable language. Every recursive language is R.E. but vice-versa is not true
Amit R Khaparde 4

That every TM hat accept recursive language must have some word for which it goes into infinite loop. A language is recursive if at least one TM accept it and reject its complement
r.e. Turing acceptable language
Recursive or Turing decidable lang Amit R Khaparde

Types of Turing machine

TM have some reasonable variations with same computational power as standard TM Variations because of following factors:
Number of tapes. More than one transition for head for same state and I / p symbol. Dimensions of tape. More than one head with a single tape. Limitation of tape expand in either direction or both direction. Presence of stationary head.
Amit R Khaparde 6

Multi-Tape TM
Contain more than one tape. Each tape has separate R/W head and transition function and connected to finite control. Tapes are divided into cell and each contain one symbol. Heads move independently. Multi tape TM can be define by 7-typle form M=(Q ,, , F, b , , q0 )
Amit R Khaparde 7

: (qi,a1,a2,a3..ak)=(qj,b1,b2,b3..bk , R,L,N) Multi tape Turing m/c is equivalent in power with standard TM.
Multi-tape TM can be converted into standard TM by placing the content of different tapes in a single tape using some delimiters.

Amit R Khaparde

Non-deterministic TM
An non-deterministic TM allows more than one edge leaving from any state with same input symbol.
I,e for some i/p symbol on the tape we may have several choices on the transition diagram to move on. I,e NTM may move to several different states on reading the same input symbol at particular state. (q ,a)={(q ,b ,R),(q ,b ,L),(q ,b ,R)}
0 1 1 2 2 3 3

Amit R Khaparde

Represented in 7-Tuple form M=(Q ,, , F, b , , q0 ) : (Q X )
Power set of (Q X )

A string said to be accepted by NTM if there exists a sequence of moves starting form initial state to final (accepting) state.

Amit R Khaparde


Other Turing Machines

Offline TM
TM which has the input tape is read only. Each move is govern by initial state , data currently read from input file and data seen by R/W head.

Multi-Head TM Multi-Dimension TM. Two way infinite TM

Amit R Khaparde 11

Properties of TM languages
Recursive language
Recursive language are closed under complementation Recursive language are closed under union.

Recursive enumerable language

The class of Recursive enumerable language are closed under union The class of Recursive enumerable language are closed under intersection operation.

A language L is recursive iff both L and complement of L is recursively enumerable

Amit R Khaparde 12

Church-Turing thesis
TM model of computation is more general than FA,PDA. TM can b design as a language acceptor, computer for a function, enumerator of a string. Primitive problem can be combine to solve more complex problem. Several TM can be composed. TM are the abstract model of computation.
Amit R Khaparde 13

In 1936 Alan Turing & Alonzo church formulate the hypothesis Any computation that can be carried out by mechanical means can be carried out by some Turing machine.
TM compute the same thing which computer can compute. No computational procedure will be considered as algorithmic procedure unless it can be represented as a TM

Unfortunately this can be proved because it is just an idea /conjecture/statement. Cannot be logically deduced from more elementary fact
Amit R Khaparde 14

Collection of all algorithmic procedures can be computed by using TM because algorithms can be made precise in form of computable function. Any computer program can be translate to TM and any TM can be translate into any general purpose programming language

Amit R Khaparde


Counter machine
Input Finite Control Accepted /Rejected

Counter 1

Counter 2

Counter 3

Counter M/c is similar to Multistack machine but in place of stack here we have counter
Amit R Khaparde 16

Counter can old any non-negative integer value but an only distinguish between zero-nonzero counter .
I,e the move of the counter machine depends on its state ,i/p symbol & which , if any, counter is 0.

The counter m/c can

Change the state. Add or subtract 1 of its counter , independently because it can have negative value therefore it cannot subtract 1 from 0.
Amit R Khaparde 17

Universal Turing Machine

TMs are mathematical models of general purpose computer.
Computer are not design to solve specific problem, they simply execute program instructions stored in their memory and these can represent any conceivable algorithm for any data

TMs are un-programmable devices , specialized at solving a particular problem. Is there a general TM that can be programmed like a general purposed computer.
Amit R Khaparde 18

Yes.. Universal Turing Machine A universal Turing machine TU
Takes two arguments: the description of computation (TM) & description of input string . The description of turing machine and input string is encoded string over finite alphabet.

Amit R Khaparde


Universal TM halts on input TM w if and only if TM halts on w. There can be more than one universal TM depending on the choice of encoding algorithm for the TM and algorithm for stimulation UTM are extremely powerful and have enough power to stimulate the behavior of any computer , other turing m/c.
Amit R Khaparde 20

It is Universal because it is capable to stimulate any other TM from the description of that m/c . According to church-Turing ,the problem solvable by UTM are exactly those solvable by a algorithm

Amit R Khaparde


Recursive languages define as set of all languages that are decided some TM. Recursively enumerable language define as a set of languages for which TM halts on accepting or rejecting state or loop in infinite loop.

Amit R Khaparde


We can divide the problem that can be solved by the TM into two categories:
The problem which TM can halt in accepting or rejecting state are called decidable.
A problem is said to be decidable if it is solvable. A language is decidable if there exists a TM M such that for all strings w:
If w belongs to L,M enter qaccept If w does not belongs L,M enter qreject. Amit R Khaparde

The problem which are not solved by TM are undecidable.
TMs may not halt at all if they do not accept it input stirng.

Problem that do not have algorithm are called undecidable.

I,e a problem is undecidable if it is unsilvable

Amit R Khaparde


Technique which is used to prove the given problem is computationally unsolvable or undecidable. Reduce the problem into another problem of previously determined decidable in such a way that the solution of first problem can be used to solve the first problem.

Amit R Khaparde


New Problem Reduce to M N Old Problem

M Solution N solution used to solve M

N solution

Solving of M cannot be harder to solving of N, because solution of N used to solve problem M. If N is Decidable then M is Decidable and if N is Undecidable then M is undecidable.

Amit R Khaparde


If a problem to new problem was found , it can be use to decide an undecidable problem ,transforming instance of undecidable problem into instance of new problem. The technique is key to prove undecidable from
In short our method for proving undecidable show that other problem are already undecidable.
Amit R Khaparde 27

When we reduce M to N , we compute function f(x) such that f(x) in N, iff x is in M
Then we can use TM for deciding N which can then be used for M.

Reduction can be define as

L1,L2 Suset of * reduction from L1 to L2 is recursive function f: * *, Such That x L1 iff f(x) L2
Amit R Khaparde 28

Important points
Reduce unsolvable problem M to another problem N. Use N solution to solve M Reduction is primary method for proving certain problem is unsolvable It is used in classifying roblem by decidability and complexity. Example of undecidable problem are emptiness problem, equivalence problem ,etc.
Amit R Khaparde 29

Halting problem
A problem is said to be solvable or decidable if there exists some algorithm which always terminate or halts.
Otherwise it is unsolvable/undecidable.

Decidable problem is also know as yes/no problems.

Wait Enough time .Yes


Turing m/c
NO . Wait Enough Forever
Amit R Khaparde 30

Churchs thesis : finding an algorithm for decidable problems is equivalent to constructing a TM which can execute the algorithm. Does the TM T applied to i/p w halt or not? Know as halting problem.
Halting problem is Decision problem.

To solve , require some mechanism to check whether give TM will halt or not. Allan Turing shows that General algorithm to solve the Halting problem does not exists .
Amit R Khaparde Halting problem is Unsolvable/undecidable Problem 31

Post correspondence Problem

Formulated by Emil post in 1940. Problem deal with the manipulation of string rather than TM or automata. The instance of PCP know as correspondence problem describe as p={[t1/s1],[t2/s2],t3/s3].tn/sn]} where as tn,sn are non-null string over . PCP concerned about the collection of domains has a match.
i.e PCP={<D>/D is set of domain with a match} It is also belong to class of yes/no
Amit R Khaparde 32

Find a match so the the w get by reading off the symbol on the top is same as the string of symbol s on the bottom
I,e w1, w2, , wk = x1, x2, , xk . Match So match is sequence i1, i2, , im of P component such that: wi1wi2wim = xi1xi2xim

w1wi1wi2wim = x1xi1xi2xim
Correspondence problem
Amit R Khaparde



Some set of domain do not match as top have more symbols then bottom. PCP is the problem to find an algorithm that tell us whether for a give post correspondence system ,there is match or not. PCP is Undecidable problem

Amit R Khaparde


i 1 2 3 A wi b bab3 ba B xi b3 ba a

This PCP instance has a solution: 2,1,1,3: w2w1w1w3= x2x1x1x3 = bab3bbba

bab3 w2 b w1 b ba w1 w3
Amit R Khaparde

ba x2

b3 x1


x1 x3

A B i wi xi 110 1 1 1 111 2 0111 10 3 4 10 0 This MPCP instance has a solution: 3, 2, 2, 4: w1w3w2w2w4 = x1x3x2x2x4 = 1101111110
Amit R Khaparde 36

i 1 2 3 A wi 01 1 1 B xi 012 10 11

Has no solution , for each substring of x and y we have x< y, hence the string generated by a sequence of substring of x is shorter than the string generated by y , Therefore PCP has no solution. Theorem :PCP over for 2 is unsolvable
Amit R Khaparde 37

i 1 2 3 A wi 10 011 101 B xi 101 11 011

Does this MPCP instance have a solution?

Amit R Khaparde 38

No Solution , because:
The first index has to be 1 because the pair 10 and 101 begin with 1. Then , whatever be index we choose to continue there will be extra 1 in first line then second line.

PCP can be act as a dominoes where upper half must be equal to lower half.
Upper half Lower half
Amit R Khaparde 39

Automata as computing machines The problem of finding out whether a given problem is SOLVABLE by automata reduces to the evaluation of function on the set of natural no/finite set of alphabets. Partial function f from x & y is a rule which assigns to every elements of x and at most one element of y. Total function f from x to y is a rule which is assign to every element of x unique element of y.
Amit R Khaparde 40

R denotes the set of all real number ,the rule F from R itself f(r)=+r1/2 is partial function , because R is not define real number when the number is negative , but g(r) = 2r is total function . We define N={0,1,2,3.} and X={a,b}*

Amit R Khaparde


Primitive recursive function

There are certain functions know as initial function and declared as primitive function.
Function Name Zero Function Successor Function Denoted Z S Definition Z(x)=0 S(x)=x+1 Uni (x1,x2,x3.xn)=xi

Projection Function Uni

Initial Function over N S(4)=5, Z(7)=0 , U33 (2,2,4)=4

Amit R Khaparde 42

Initial Functions over {a,b}
Function Name Nil Definition Nil

Concatenation a
Concatenation b

Cons a(x)
Cons b(x)

Nil(abab)= ,cons a(abab)=aabab, cons b(abab)=babab If f1, are partial function of n variables and g is partial function of k variables then composition of g and f1, is a partial function of n variables defined by g(f1(x1,x2,xn),f2(x1,x2,xn ).f3(x1,x2,xn))
Amit R Khaparde 43

F1 (x,y)=x+y,f2(x+y) =2x, f3(x,y)=xy g(x,y,z) =x+y+z g(F1 (x,y), f2(x+y), f3(x,y)) = g(x+y,2x,xy)= x+y+2x+xy = h(x,y); F1 (x,y)=x-y,f2(x+y) =y-x, f3(x,y)=xy g(x,y) =x+y Answer g(0,0)=0; F1 (x,y)=x*y,f2(x+y) =null, f3(x,y)=x g(x,y,z) =yz Answer x; A function f(x) over N is said to be recursive if there exists a constant k (a natural number ) and a function h(x , y ) such that : F(0) =k, f(n+1) =h (n , f(n))
Amit R Khaparde 44

Define factorial of n i,e n!
F(0)=1, f(n+1) = h(n,f(n)) where as h(x,y)=s(x)*y
F(0) = 3 * 2 F(3) = F(2+1) = h(2,F(2)) = S(2)*F(2) = 3*F(2) F(2) = 2 * 1 F(2) = F(1+1) = h(1,F(1)) = S(1)*F(1) = 2*F(1) F(1) = 1 *1

F(1) = F(0+0) = h(0,F(0)) = S(0)*F(0) = 1*F(0)

F(0) = 1
Amit R Khaparde 45

The above definition of above definition can be generalized for f(x1,x2,xn, xn+1) Fix n variables in f(x1,x2,xn, xn+1) i,e x1,x2,xn Apply the definition to f(x1,x2,xn, y) , in place of k we will get g(x1,x2,xn) and in place of h(x,y) we will have h ( x1,x2,..xn , y, f(x1,x2,xn, y) )

Amit R Khaparde


A function f of n+1 variables is defines by recursion if there exists a function g of n variables , and a function h of n+2 variables and f is defined as follows :
f(x1,x2,.xn,0)=g(x1,x2,xn) f( x1,x2,.xn,y+1) = h(x1,x2,..xn , y ,f(x1,x2,..xn , y ))

Amit R Khaparde


Primitive Recursive function over N

A total function f over N is called primitive recursive ,if :
If it is any one of three initial functions If it can be obtained by applying composition and recursion a finite number of times to the set of initial function.

Amit R Khaparde


F1(x,y) = x+y is primitive recursive If we want f1 to be defined by recursion , therefore g is 1 variable function h is 3 variable function F1(x,0)=x+0=x, compare it with definition g(x)=x=U11(x) F1( x,y+1 ) = x+( y+1 ) = ( x + y )+1 = F1(x , y ) +1 h (x , y , F1( x , y ))= F1(x , y ) +1=s( F1(x , y ) ) = s(U33(x , y, F1(x , y ) +1)
Amit R Khaparde


F(2,3) = F(2,2+1) = h(2,2,F(2,2)) = S(U33(2,1,F(2,2))

F(2,2) = F(2,1+1) = h(2,1,F(2,1)) = S(U33(2,1,F(2,1))

F(2,1) = F(2,0+1) = h(2,0,F(2,0)) = S(U33(2,1,F(2,0)) F(2,0) = 2+0

2+3 = 5
F(2,0) = 2 F(2,1) = s(U33(2,0,F(2,0)))=s(U33(2,0,2))=s(2)=3 F(2,2) = S(U33(2,1,F(2,1)))=s(U33(2,1,3))=s(3)=4

F(2,3) = S(U33(2,2,F(2,2)))=s(U33(2,1,4))=s(4)=5
Amit R Khaparde 50

The function f2(x,y)=x*y The multiplication of two natural numbers is simply repeated addition.

F2(x,0) = 0; f2(x,y+1)=x*(y+1)=f2(x,y)+x F2(x,y+1)=sum( mul ( x , y ) , x) = f1(f2(x ,y ),x)

By comparing these with definition f2(x,0) =z(x) and f2(x,y+1)=f1(u33(x,y,f2(x,y)),u31(x,y,f2(x,y)))) Putting g=Z and h defined by h(x,y,z) = f1(U33(x,y,z),U13(x,y,z))
Amit R Khaparde 51

F(2,3) = F(2,2+1)= f1(u33(2,2,f2(2,2)),u31(2,2,f2(2,2))))

F(2,2) = F(2,1+1)= f1(u33(2,1,f2(2,1)),u31(2,1,f2(2,1))))

F(2,1) = F(2,0+1) = f1(u33(2,0,f2(2,0)),u31(2,0,f2(2,0)))) F(2,0) = 0 F(2,0) = 0 2*3 = 6

F(2,1) = f1(u33(2,0,f2(2,0)),u31(2,0,f2(2,0)))) = f1(u33(2,0,0),u31(2,0,0))=f1(0,2)=0+2=2

F(2,2) =f1(u33(2,1,f2(2,1)),u31(2,1,f2(2,1)))) = f1(u33(2,1,2),u31(2,1,2))=f1(2,2)=2+2=4

F(2,3) =f1(u33(2,2,f2(2,2)),u31(2,2,f2(2,2)))) = f1(u33(2,2,4),u31(2,2,4))=f1(4,2)=4+2=6
Amit R Khaparde 52

F(x,y) =xy is primitive recursive. Here , f(x,y)=1 and f(x,y+1)=x*f(x,y)
U13(x,y,f(x,y)) * (U33(x,y,f(x,y))

F2(U13(x,y,f(x,y)) , (U33(x,y,f(x,y)) The Predecessor function p(x) defined by P(x) =x-1 if x not equal to 0,p(x)=0 if x=0 p(0) =0 , p(y+1)=U12(y,p*(y)) Proper subtraction function define as x-y=y-x if x y and x-y =0 if xy x-0=x and x-(y+1) = u21(y,p(y))

Amit R Khaparde


The absolute value function I I given by
IxI = x if x0,IxI=-x if x<0

Ix-yI = (x-y)+(y-x) Min(x,y) Min(x,y) = x-(x-y) First function is defined recursive using initial function hence it is primitive recursive Other being proved with the help of first one hence they are also recusive.
Amit R Khaparde


Primitive Recursive over {a,b}

The process is same as previous one , but certain modification. A function f(x) over is defined by recursion if there exists a constant string w * and function h1(x,y) and h2(x,y) such that
F() = w F(ax) = h1(x,f(x)) F(bx)=h2(x,f(x))
Amit R Khaparde 55

A function f(x1,x2,..xn) over is defined by recursion if there exists function g(x1,x2,xn-1), h1(x1,x2,.xn+1) h2(x1,x2,.xn+1) such that F(,x2,.xn) = g(x2,xn) F(ax1,x2xn)=h1(x1,x2,..xn)f(x1,x2,.xn)) F(bx1,x2xn)=h2(x1,x2,..xn)f(x1,x2,.xn)) A total function is primitive If it is any one of three initial functions If it can be obtained by applying composition and recursion a finite number of times to the set of initial function.
Amit R Khaparde 56

Recursive Function
More function on function , it include primitive recursion . Let g(x1,x2,.xn, y) be a total function over N, g is a regular function if there exists some natural y0 Such That g(x1,x2,.xn, y0) =0 for all x1,x2,.xn in N.

Amit R Khaparde


A function f(x1,x2,..xn) over N is defined from a total function g(x1,x2,..xn ,y) by minimization if
f(x1,x2,..xn) is the least value of all ys such that g(x1,x2,..xn ,y) =0 if it exists , then least value is denoted by y(g(x1,x2,..xn ,y) =0) f(x1,x2,..xn) is undefined if there is no y such that g(x1,x2,..xn ,y) =0

Amit R Khaparde


A function is recursive if it can be obtain from initial functions by finite number of application of composition , recursion, minimization over regular functions. A function is partial recursive if it can be obtained from initial functions by finite number of application of composition , recursion, minimization .
Amit R Khaparde 59

Ackermanns function
A(0,y)=y+1 A(x+1,0)=a(x,1) A(x+1,y+1)=A(x , A(x+1,y))

Amit R Khaparde


A(1,1) = A(0+1,0+1) A(0+1,0+1)=A(0,A(1,0)) A(1,1)=A(0,2)=3 A(0,A(1,0))=A(0,A(0,1)) A(0,A(0,1))=A(0,2)

A(1,2) = A(0+1,1+1)


A(0,A(1,1)) =A(0,3))


A(2,1) = A(1+1,0+1)



A(0+1,2+1)=A(0,A(1,2)) A(0,A(1,2))=A(0,4)

A(0,4)=5 Amit R Khaparde

A(1,5) 7 A(2,2) 7

Amit R Khaparde