Theory of Computation: Lecture #4
Theory of Computation: Lecture #4
Lecture #4
Sarmad Abbasi
Virtual University
We define our TM M
1 Q = {q1 , . . . , q14 , qa , qr }
2 Σ = {0, 1, #}
3 Γ = {0, 1, #, x, }
4 q1 , qa , qr the start, accept and reject states respectively.
5 δ is given by the state diagram.
In this diagram we have not shown qr . All transitions not defined here
go to qr .
011#011.
As you can see in the first phase the machine has converted the input
into
11#011.
Now it is looking for a 0 in the second string. When it finds a 0 it
crosses it and starts all over again.
Next it crosses of the 1 and is looking for a 1 in the second string.......
x1#x11
and is looking for a 1.
x1#xx1
Now it goes back and similarly matches the last 1 to finally reach
xx#xxx
Then it goes over the tape once and realizes that all things have been
matched so it accepts this input.
C = {ai bj c k : k = i × j i, j, k ≥ 1}.
Firstly all the strings in this language have a’s then b’s then c’s.
Some strings in the language are:
x 0 abbbcccccc.
Since there are three b’s we shuttle between b’s can c’s crossing them
off.
To get to
x 0 axxxxxxccc
Next there is still an a so we restore all the b’s to get
x 0 abbbxxxccc
x 0 xbbbxxxccc.
Now, shuttle between b’s and c’s crossing them off to get
x 0 xxxxxxxxxx
.
Now check if there are any a’s left. No so we accept.
One question.
Why is the left most x and x 0 .
The answer is that this way the machine will know that it has reached
the left end of the tape.
i ×j
we accept.
#0#1011#000
It is first compared with the second string.
#0#10#11#000
then
#0#10#11#000
#0#10#11#000
then
#0#10#11#000
then
#0#10#11#000
after comparing them we are done.
From now on. We will only give informal description of TM’s. But, you
should be able to convert any informal description to a formal one.
Most interesting TM have several states hundreds even thousands.
However, it will be clear that an informal description can be changed to
a formal one.