0

Can anyone explaine me how to do Turing machine for following:

Y= X mod 3, where (X, Y) binary numbers with minimum time complexity 10

enter image description here

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Anton
  • 227
  • 2
  • 11
  • What do you mean by "minimum complexity 10"? – blubb Feb 25 '14 at 19:48
  • @blubb sorry, minimum time complexity – Anton Feb 25 '14 at 19:50
  • 1
    Do you have a definition for "time complexity n"? I don't think it's commonly known. – blubb Feb 25 '14 at 19:52
  • @blubb in russian it is "с минимальной временной сложностью 10". Cant say what this mean – Anton Feb 25 '14 at 19:54
  • Which is the most significant bit of X? Is it X0 or X7? And how would you calculate x mod 3 with paper and pencil? – Beta Feb 25 '14 at 20:02
  • @Beta [link](https://dl.dropboxusercontent.com/u/27865855/IMG_20140225_220758.jpg) . About X, I dont know – Anton Feb 25 '14 at 20:10
  • It's easier if x0 is the most significant bit. Now if I give you a binary number (with the most significant bit on the left, for now) like 111010 (58), how would you calculate modulo three, using a pencil? – Beta Feb 25 '14 at 20:19
  • @Beta 58 mod 3 = 19 + 1 =1 – Anton Feb 25 '14 at 20:23
  • You're doing the division in your head, and retaining 19, which you don't really need. Imagine you are not smart enough to remember large numbers, and I give you 839690268389321792. *How* do you calculate modulo 3? – Beta Feb 25 '14 at 20:30
  • @Beta I dont know. Pls, just help me to solve my question – Anton Feb 25 '14 at 20:32
  • I am trying to help you. I will not give you a Turing machine to give to your teacher; you must understand the machine. If you do not understand modulo, it is almost impossible to understand the machine. Here is the way to do it. Start at the left and perform the operation on the first digit: 8->2. Append the next digit and operate again: 23->2. Repeat: 29->2. Repeat: 26->2. Keep repeating: 29->2, 20->2, 22->1, 16->1, 18->0, 03->0, 08->2, 29->2, 23->2, 22->1, 11->2, 27->0, 09->0, 02->**2**. It's easier in binary. – Beta Feb 25 '14 at 20:43
  • @beta I understand your logic but I still not have any idea how to do this. – Anton Feb 25 '14 at 21:06
  • Do you mean that you don't know how to calculate the remainder in a simple-minded way, or you don't know how to build a Turing machine that will do that? – Beta Feb 25 '14 at 21:16
  • @Beta I dont know how to build Turing machine for this. – Anton Feb 25 '14 at 21:18

2 Answers2

3

All right, you understand the algorithm, now we must build the machine.

We will start with the number 111010 (58), reading from left to right, with the machine head starting at the left. There are two modes: scanning to the right to see what is there, and moving to the left while rewriting.

|
v
x111010m
abcdefgh

(I have marked the positions a-h, for our conversation.) What should the machine do?

In a Turing machine, a state has several rules, so that the machine can decide what to do by which symbol it sees. The rules for state A can look like:
"If I see the symbol x, I will erase it and write the symbol v, move one step to the left and enter state B."
"If I see the symbol y, I will leave it undisturbed, move one step to the right and enter state D."
"If I see the symbol w, I will erase it and write the symbol z, move one step to the left end enter state A (remain in this state)."

In general, it scans to the right, to discover whether the number begins with 11, 100 or 101. This involves two different states. It then moves to the left, rewriting 11->xx, 100->xx1, 101->x10. This involves several states.

In the case of 111010, it the first few moves will look like this:
(a) In state 1, read x, leave it undisturbed, move right, remain in state 1. (Looking for 1.)
(b) In state 1, read 1, leave it undisturbed, move right, go to state 2. (What comes next?)
(c) In state 2, read 1, write x, move left, go to state 3. (Must rewrite this symbol as x and the previous one as x.)
(b) In state 3, read 1, write x, move right, go to state 1. (Looking for 1 again.)

(If you are clever you can do without state 3, but let's get the machine working first.)

So I can write some of the rules like this:

1 x x right 1
1 1 1 right 2
2 1 x left  3
3 1 x right 1

You must write enough rules that the machine always knows what to do, and if you want the machine to stop (yes!) there must be a rule -- or many rules -- like this:

5 m m right halt

Is this enough to get you started?

Beta
  • 96,650
  • 16
  • 149
  • 150
  • It is the number that bigger on 3 but has the same mod. – Anton Feb 25 '14 at 21:03
  • You write it clearly. MAy be I so stuped. I still dont know how to do this machine at all(( – Anton Feb 25 '14 at 21:47
  • What machine do you know? Can you add it to your question? – Beta Feb 25 '14 at 21:53
  • Really, no one. Turing machine is first that we study. But because of the revolution in Kiev canceled a lecture on which it had to say, and laboratory work still have to be done for tomorrow ( – Anton Feb 25 '14 at 21:58
  • @Anton: This will be difficult. I can explain a Turing machine, but I do not know what you have studied. The Russian Wikipedia page is [here](http://sr.wikipedia.org/wiki/%D0%A2%D1%98%D1%83%D1%80%D0%B8%D0%BD%D0%B3%D0%BE%D0%B2%D0%B0_%D0%BC%D0%B0%D1%88%D0%B8%D0%BD%D0%B0), the English [here](http://en.wikipedia.org/wiki/Turing_machine) (the English is better, but in English). Are you familiar with the idea of a *state machine* or a flowchart? – Beta Feb 25 '14 at 22:15
  • Yes. I pass them. We will not study Turing machine. It is just one lab work. – Anton Feb 25 '14 at 22:19
  • Good. A Turing machine is a state machine that can read and write symbols on a tape, and move to the left and right. It has a finite number of internal states, and a finite alphabet of symbols, but the tape is endless in both directions. Does that make sense? – Beta Feb 25 '14 at 22:23
  • Got it. I dont know, maybe) – Anton Feb 25 '14 at 22:29
  • I know, you know how to build this machine. Pls, build it, and I will try to understand it better) – Anton Feb 25 '14 at 22:32
  • @Anton: No. If you understand what I have written, you can build the rest of the machine; if I build the whole machine for you, you will give it to your teacher dishonestly and learn nothing. – Beta Feb 25 '14 at 22:52
0

I made it.

Here is working machine)

enter image description here

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Anton
  • 227
  • 2
  • 11