A Turing Machine for the language \(\mathrm{L}=\left\{\mathrm{a}^{\mathrm{n}}…

2022

A Turing Machine for the language \(\mathrm{L}=\left\{\mathrm{a}^{\mathrm{n}} \mathrm{b}^{\mathrm{m}} \mathrm{c}^{\mathrm{n}} \mathrm{d}^{\mathrm{m}} \mid \mathrm{n} \geq 1, \mathrm{~m} \geq 1\right\}\) is designed. The resultant model is \(M =\)\(\left(\left\{\mathrm{q}_{0}, \mathrm{q}_{1}, \mathrm{q}_{2}, \mathrm{q}_{3}, \mathrm{q}_{4}, \mathrm{q}_{5}, \mathrm{q}_{6}, \mathrm{q}_{7}, \mathrm{q}_{\mathrm{f}}\right\},\{\mathrm{a}, \mathrm{b}, \mathrm{c}, \mathrm{d}\},\left\{\mathrm{a}, \mathrm{b}, \mathrm{c}, \mathrm{d}, \mathrm{X}_{1}, \mathrm{X}_{2}, \mathrm{Y}_{1}, \mathrm{Y}_{2}\right\}, \delta, \mathrm{q}_{0}, \mathrm{~B},\left\{\mathrm{q}_{\mathrm{f}}\right\}\right)\) and part of \(' 𝛿 '\) is given in the transition table. You need to write the following questions based on design of Turing Machine for the given language. Note that, while designing the Turing Machine \(X_1\) and \(X_2\) are used to work with \(′𝑎′𝑠\) and \(′𝑐′𝑠\) and \(Y_1\) and \(Y_2\) are used to handle \(′𝑏′𝑠\) and \(′𝑑′𝑠\) of the given string.

\(\begin{array}{|c|c|c|c|c|c|c|c|c|c|} \hline & \mathrm{a} & \mathrm{b} & \mathrm{c} & \mathrm{d} & \mathrm{X}_{1} & \mathrm{X}_{2} & \mathrm{Y}_{1} & \mathrm{Y}_{2} & \mathrm{~B} \\ \hline \mathrm{q}_{0} & \left(\mathrm{q}_{1}, \mathrm{X}_{1}, \mathrm{R}\right) & & & & \mathrm{M} 2 & & & & \\ \hline \mathrm{q}_{1} & \left(\mathrm{q}_{1}, \mathrm{a}, \mathrm{R}\right) & \left(\mathrm{q}_{1}, \mathrm{~b}, \mathrm{R}\right) & \mathrm{M} 1 & & & \left(\mathrm{q}_{1}, \mathrm{X}_{2}, \mathrm{R}\right) & & & \\ \hline \mathrm{q}_{2} & \left(\mathrm{q}_{2}, \mathrm{a}, \mathrm{L}\right) & \left(\mathrm{q}_{2}, \mathrm{~b}, \mathrm{~L}\right) & & & \left(\mathrm{q}_{2}, \mathrm{X}_{1}, \mathrm{R}\right) & \left(\mathrm{q}_{2}, \mathrm{X}_{2}, \mathrm{~L}\right) & & & \\ \hline \mathrm{q}_{3} & \mathrm{M} 3 & \left(\mathrm{q}_{4}, \mathrm{Y}_{1}, \mathrm{R}\right) & & & & \left(\mathrm{q}_{6} \mathrm{X}_{2}, \mathrm{R}\right) & & & \\ \hline \mathrm{q}_{4} & & \left(\mathrm{q}_{4}, \mathrm{~b}, \mathrm{R}\right) & & \left(\mathrm{q}_{5}, \mathrm{Y}_{2}, \mathrm{~L}\right) & & \mathrm{M} 5 & & \left(\mathrm{q}_{4}, \mathrm{Y}_{2}, \mathrm{R}\right) & \\ \hline \mathrm{q}_{5} & & \left(\mathrm{q}_{5}, \mathrm{~b}, \mathrm{~L}\right) & & & & \left(\mathrm{q}_{5}, \mathrm{X}_{2}, \mathrm{~L}\right) & \mathrm{M} 4 & \left(\mathrm{q}_{5}, \mathrm{Y}_{2}, \mathrm{~L}\right) & \\ \hline \mathrm{q}_{6} & & & & & & \left(\mathrm{q}_{6}, \mathrm{X}_{2}, \mathrm{R}\right) & & \left(\mathrm{q}_{7}, \mathrm{Y}_{2}, \mathrm{R}\right) & \\ \hline \mathrm{q}_{7} & & & & & & & & \left(\mathrm{q}_{7}, \mathrm{Y}_{2}, \mathrm{R}\right) & \left(\mathrm{q}_{6}, \mathrm{~B}, \mathrm{R}\right) \\ \hline \end{array}\)


What is the Move in the cell with number \(' M1 '\) of the resultant Table?

  1. A.

    \(\left(\mathrm{q}_{2}, \mathrm{X}_{2}, \mathrm{R}\right)\)

  2. B.

    \(\left(\mathrm{q}_{2}, \mathrm{X}_{2}, \mathrm{~L}\right)\)

  3. C.

    \(\left(\mathrm{q}_{3}, \mathrm{X}_{2}, \mathrm{~L}\right)\)

  4. D.

    Error Entry

Attempted by 26 students.

Show answer & explanation

Correct answer: B

The machine must check the structure:

  • Mark one unmatched ‘a’ → X₁

  • Match it with one ‘c’ → X₂

  • And separately

  • Match one ‘b’ → Y₁

  • with one ‘d’ → Y₂

So the machine repeatedly performs two matching loops:

Loop 1: Match a ↔ c

  1. Find next unmarked a, convert it to X₁, go right.

  2. Find the matching c, convert it to X₂, go left to return.

Loop 2: Match b ↔ d

  1. Find next unmarked b, convert it to Y₁, go right.

  2. Find the matching d, convert it to Y₂, go left to return.

Where M1 Occurs

Look at the table row:

  • State = q₁

  • Symbol = c

  • Entry = M1

This means:

δ(q1,c)=M1\delta(q_1, c) = M1δ(q1​,c)=M1

Now we must understand:
What should the TM do when it is in state q₁ and reading a ‘c’?

Understanding state q₁

State q₁ appears after:

  • Machine has just marked an ‘a’ as X₁

  • And is now moving right to find:

    • first b (for Y₁ marking), OR

    • first c (for X₂ marking)

In language anbmcndma^n b^m c^n d^manbmcndm, the order is:

anbmcndma^n \quad b^m \quad c^n \quad d^manbmcndm

So when the machine reaches the c block, it must:

✔️ Mark one c → X₂

✔️ Then return to the left to find the next a or b loop

This is exactly what M1 does.

Why M1 = (q₂, X₂, L)?

Let’s check step-by-step.

The TM is in q₁

  • It has already matched an a

  • Now it is searching for a corresponding c

✦ It reads symbol c

This means it has reached the c-block.

✦ It should mark this c as processed:

c→X2c \rightarrow X_2c→X2​

✦ After marking, the machine must return left

Why? Because it must go back to:

  • the b-marking phase, or

  • the next a-marking phase

That is why the move direction = L.

✦ It must now go to state q₂

State q₂ is designed for moving left until the machine reaches the boundary zone (the left side of the alphabet blocks).

So:

M1=(q2,  X2,  L)\boxed{M1 = (q_2,\; X_2,\; L)}M1=(q2​,X2​,L)​

is exactly correct for both logic and direction control.

M1=(q2,  X2,  L)\boxed{M1 = (q_2,\; X_2,\; L)}M1=(q2​,X2​,L)​

This marks a “c” as X₂, then moves left in state q₂ to continue matching.

Explore the full course: Mppsc Assistant Professor