3

I understood the logic of Turing machine. When the Turing machine is given , i can understand how it is working and how it halts. But when it is asked to construct a Turing machine , it is more difficult.

Is there any easy way to find the answer of questions such as :

Construct a Turing machine a*b* 
Construct a Turing machine a*b*a* 
etc.

I want to diagram these Turing machine? Is there any method, like table filling and then diagramming it ,etc.?

I searched a lot on the web about this topic . There are only answers (only diagrams). There are no explanation how it is solved how it is diagrammed.

Thanks in advance

Jared Farrish
  • 48,585
  • 17
  • 95
  • 104
oiyio
  • 5,219
  • 4
  • 42
  • 54
  • 1
    I didn't know what it exactly is . After you said , i searched and learned it :)thanks – oiyio Aug 25 '12 at 22:41

1 Answers1

0

The two examples you give are regular expressions, and there are indeed easy algorithmic ways of turning regular expressions into automata - namely, NFAs. Once you have NFAs, you can turn them into TMs using a simple construction.

The algorithm to turn regular expressions into NFAs goes like this:

Rule 1: If r = a for some alphabet symbol a, then the NFA for r is:

       a
--->q0--->(q1)

Rule 2: If r = st for regular expressions s, t, and M1 and M2 are NFAs for s and t, respectively, then the NFA for r is:

       e
--->M1--->M2

That is, the initial state is that of M1, the accepting states are those of M2, and there are new empty transitions from all the (formerly) accepting states of M1 to the (formerly) initial state of M2.

Rule 3: if r = s + t, for regular expressions s, t, and M1 and M2 are NFAs for s and t, respectively, then the NFA for r is:

       e
--->q0--->M1
     | e
     +--->M2

That is, the initial state is a new state q0, the final states are those of both M1 and M2, and two empty transitions are added leading from the new initial state to the (formerly) initial states of both M1 and M2.

Rule 4: If r = s* for regular expression s, and M is a NFA for s, then a NFA for r is:

     +------+
     |  e   |
     V      |
--->(q0)--->M

That is, a new initial state q0 is added, the accepting states are those of M along with q0, and new empty transitions are added from the accepting states of M to q0.

In your examples, we derive NFAs as follows:

a: Rule 1           a
             --->q0--->(q1)

b: Rule 1           b
             --->q0--->(q1)

a*: Rule 4         +-------------+
                   |      e      |
                   V             |
             --->(q0)--->q0'--->(q1)
                      e      a

b*: Rule 4         +-------------+
                   |      e      |
                   V             |
             --->(q0)--->q0'--->(q1)
                      e      b

a*b*: Rule 2      +-----------+
                  |           | e
                  V e      a  |
             --->q0--->q0'--->q1
                  |           |
                e |           | e
                  +-----------+--+
                  |              | e
                  V   e      b   |
                 (q2)--->q2'--->(q3)

a*b*: Rule 2      +-----------+
                  |           | e
                  V e      a  |
             --->q0--->q0'--->q1
                  |           |
                e |           | e
                  +-----------+
                  |           | e
                  V  e    b   |
                 q2--->q3'--->q3
                  |           |
                e |           | e
                  +-----------+--+
                  |              | e
                  V   e      a   |
                 (q4)--->q5'--->(q5)

With a NFA in hand, a TM can be constructed as follows:

  1. Same states as the NFA
  2. Transitions which consume an input move the tape head right.
  3. Transitions which are empty do not move the tape head at all.
  4. The TM never overwrites its input.
  5. When the TM encounters a blank after moving right far enough, it enters halt-accept if it's in an accepting state for the DFA, or halt-reject otherwise.
Patrick87
  • 27,682
  • 3
  • 38
  • 73