Tải bản đầy đủ (.pdf) (8 trang)

3 turing machine ( solved examples ) mp4

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (140.1 KB, 8 trang )

(00:01)
Hello, everyone.
(00:02)
Welcome to the next lecture.
(00:04)
In the course and Theory of Atom Meta.
(00:08)
In the previous lecture we studied
the formal definition of a Turing machine,
(00:14)
and in this lecture we will see two
examples of Turing machine,
(00:18)
and we will see how we design a Turing
machine for a given language.
(00:22)
All right.
So let's get started.
(00:26)
Here we have an example for designing
(00:28)
of a Turing machine which recognizes the
language L equal to zero, one star zero.
(00:35)
So what this language mean?
(00:37)
This language mean?
(00:39)
It should have one0 followed by any number
of ones followed by one0 at the end.
(00:46)


So if you look, it is a regular language,
(00:49)
and we can easily design a finite
state machine for this language.
(00:54)
But we design theorem machine for this
(00:56)
language so that we can understand the
machine from the very simplest example.
(01:02)


So here I have designed the Turing
machine for the language.
(01:06)
So here we have the starting
state, which is a.
(01:10)
Then we have two States B and C,
(01:13)
and then we have two final States, which
are the reject and the except state.
(01:18)
Let us see how it works.
(01:21)
So as we want to accept
zero, one star zero.
(01:25)
So at the initial state,
(01:27)

when we get a zero,
we go to the next state B,
(01:31)
and in our tape we write symbol X,
and we move to the right on our tape.
(01:38)
So we are now instead B.
(01:41)
So now we know that we have to accept any
(01:45)
number of ones after we have
accepted the zero at the start.
(01:49)
So instead B, if you get any number
of ones, you always stay instead B.
(01:55)
And then on the tape we write Y
and we move right on the tape.
(02:01)
And after getting any number of ones,
finally, we need to get a zero.
(02:06)
So if we get a zero, we move to the next
state C, and we write X on tap.


(02:13)
And then we move right on the tap.
(02:18)
And after reaching this state C, we see

that there is nothing more to take.
(02:23)
So what we do, we read the blank
symbol that is the spacious symbol.
(02:28)
So when we read the blank symbol,
we do not write other symbol other than
(02:33)
the blank symbol, and we
move to the accept state.
(02:38)
So this is how it works.
(02:41)
Now let us take an example string
(02:43)
from this language, which is 0110 and let
us see how it works using the tape.
(02:51)
So we come to the tape and our head
is at the leftmost cell of our tape.
(03:02)
So when we get a zero,
(03:04)
we write X on our tap, and we go to step
B, and we move to the right under tab.
(03:13)
Now our next input is one.
(03:18)
So if we get a one,
(03:19)

we are instead B and we write a y
onto our tape, and we remain in step
(03:41)
B.
But we move to the right on our tape,
(03:45)
and then the next input we have is a zero.


(03:48)
So when we get zero at state B,
we move to the state C and we write X onto
(03:54)
our tape, and we move one
step to the right on the tab.
(04:00)
Now we see that we have reached
to the end of the string.
(04:04)
So after the zero at the end,
we consider it to be the blank symbol.
(04:11)
So we are at state C,
and we encounter a blank symbol.
(04:15)
So we write blank symbol on the tab,
(04:18)
and we move one step to the right
and we go to the accept state.
(04:25)

So the string 0110 is accepted.
(04:29)
And now this is the condition of our tape.
(04:34)
Now you may ask why we write
these X and y onto the tape.
(04:41)
So as this was a very simple example
language, and we actually do not need
(04:46)
the full power of Turing machine
in order to implement this.
(04:50)
But we have to do this because we are
(04:53)
using the Turing machine,
and particularly for this language,
(04:57)
these tape symbols have no such specific
meaning, but we just do it in order


(05:02)
to show how Turing machine works and how
Turing machine tape actually works.
(05:08)
Also, in the first lecture on Turing
(05:10)
machine, I told you that Turing
machines are deterministic.

(05:14)
So here in this transition diagram, you
see, we have transition for every input.
(05:21)
Now let us discuss another example
(05:25)
in which we design a Turing machine for
the language zero power n one power N.
(05:31)
So it means we have to design a Turing
machine for a language where number
(05:35)
of zeros should exactly be equal to the
number of ones that follow these zeros.
(05:43)
In the previous lecture,
when we were discussing finite state
(05:47)
machines, we saw that we could not
implement this language using finite state
(05:54)
machine because we need to keep count
of how many zeros are there in order
(06:00)
to repeat the exact same number of ones
so that we can implement this language.
(06:05)
But we saw that finite state machine due
to their limited memory and due to their
(06:10)

limited capability,
it was not possible to design a finite
(06:14)
state machine, and therefore we declared
that this was not a regular language.


(06:21)
So we shall see using a Turing machine,
how can we design this language?
(06:25)
So first of all, I will explain to you
the algorithm of how this can be done.
(06:33)
We first will design an algorithm
(06:35)
which will accomplish this task
of accepting this kind of strings.
(06:40)
And then from that algorithm,
(06:42)
we will see how we design
the equivalent Turing machine for it.
(06:47)
All right.
So here you see, we have the tape sequence
(06:51)
in our Turing machine,
and then we have the algorithm.
(06:56)

So the first step in algorithm says
change zero to X.
(07:03)
So we replace the first zero in our tape
(07:05)
to X, and then we move right
until we find the first one.
(07:10)
So if you cannot find the one,
(07:12)
then you have to reject means
that the string will not be accepted.
(07:18)
And if you are able to find a one,
then you have to change it to Y.
(07:24)
And after you do that,
you have to move left until you find


(07:28)
the leftmost zero, and this process will
be repeated until no more zeros are there.
(07:34)
And also you have to make sure
that no more ones remain as well.
(07:40)
Now let us apply this algorithm
on our tap in the Turing machine.
(07:45)

You notice in the tape that we have four
number of zeros and four number of ones.
(07:50)
So the number of zeros are same
to the number of ones that follow.
(07:57)
So
(07:59)
this string should be accepted.
(08:03)
So first of all, our tape head is
about the leftmost zero in our tab.
(08:12)
So as in our algorithm,
(08:14)
the first step we perform is
to change this X this zero to X.
(08:20)
Then we move right on the tape
(08:24)
until we find the first one.
(08:27)
So here I have found the first one.
(08:31)
So according to the algorithm,
we change it to a Y,
(08:36)
and then what we have to do, we have
to move left to the leftmost zero.
(08:44)

So I move step by step to the leftmost
zero, and I find that my left most zero is


(08:51)
here, so we change it to X
according to the algorithm.
(08:57)
So after replacing the lift most zero
(08:59)
with X, I again move to the right
until I find my first one.
(09:06)
I change it to Y.
(09:09)
Then I start moving left until I find the
leftmost zero, and I change it to an X.
(09:17)
Then again, I repeat these steps
(09:22)
and I start moving to the right
and I find my first one.
(09:29)
So I changed it to Y,
(09:31)
then start moving left, and finally I see
my left most and also the final zero.
(09:38)
I change it to X, and then I move right
and I find the first and the last one.

(09:48)
So I change it to Y.
(09:53)
Now, if we look, there are no more
zeros and also there are no more ones.
(09:59)
So our tape.



×