2080 2

CSC262 · 2080 · 10 marks

How does Turing machine accept a string? Design a Turing Machine over the alphabet {0,1,a} that processes the string defined by L = {a01a,a10a,a0101a}. Show both transition diagram and table. Show acceptance of a0101a.

How does Turing machine accept a string? Design a Turing Machine over the alphabet {0,1,a} that processes the string defined by L = {a01a,a10a,a0101a}. Show both transition diagram and table. Show acceptance of a0101a.[10]

Theory of ComputationChapter 6: Turing MachinesAcceptance of a string by a Turing MachinesNumerical: Turing machine string acceptance

Turing Machine for L = {a01a, a10a, a0101a}

Given

  • Alphabet (Σ): ${0, 1, a}$
  • Language: $L = {a01a,\ a10a,\ a0101a}$ (a finite language of exactly 3 strings)
  • Tape symbols (Γ): ${0, 1, a, B}$ where $B$ = blank
  • Required: definition of acceptance, TM design, transition diagram, transition table, trace of a0101a

Solution

1. How a Turing Machine Accepts a String

A Turing Machine is a 7-tuple: $$M = (Q, \Sigma, \Gamma, \delta, q_0, B, F)$$

  • $Q$: finite set of states
  • $\Sigma$: input alphabet
  • $\Gamma$: tape alphabet ($\Sigma \subseteq \Gamma$, includes $B$)
  • $\delta: Q \times \Gamma \rightarrow Q \times \Gamma \times {L, R}$: transition function
  • $q_0$: initial state
  • $B$: blank symbol
  • $F \subseteq Q$: set of final (accepting) states

Acceptance process:

  1. The input string $x$ is written on the tape, surrounded by blanks $B$.
  2. The head starts at the leftmost symbol of $x$; machine begins in $q_0$.
  3. At each step the machine reads the current cell, uses $\delta$ to write a symbol, move (L/R), and change state.
  4. A string is accepted if the machine halts in a final state ($q \in F$).
  5. It is rejected if it halts in a non-final state or never halts.

$$L(M) = { x \in \Sigma^* \mid q_0 x \vdash^* \alpha, q_f, \beta,\ q_f \in F}$$

2. Design Strategy

Since $L$ is finite (3 exact strings), the TM scans left-to-right, tracking progress through the shared prefix a, then branching. Since we only recognize, we write back the same symbol and move R.

States:

StateMeaning
$q_0$expect leading a
$q_1$after a; expect 0 or 1
$q_2$after a0; expect 1
$q_3$after a01; expect final a or continue 0
$q_4$after a1; expect 0
$q_5$after a10; expect final a
$q_6$after a010; expect 1
$q_7$after a0101; expect final a
$q_8,q_9,q_{10}$after trailing a; verify blank end
$q_a$accept (final)
$q_r$reject

3. Transition Table

$\delta(\text{state},\text{read}) = (\text{write},\text{move},\text{next})$

StateReadWriteMoveNext
$q_0$aaR$q_1$
$q_0$0,1,B--$q_r$
$q_1$00R$q_2$
$q_1$11R$q_4$
$q_1$a,B--$q_r$
$q_2$11R$q_3$
$q_2$0,a,B--$q_r$
$q_3$aaR$q_8$
$q_3$00R$q_6$
$q_3$1,B--$q_r$
$q_4$00R$q_5$
$q_4$1,a,B--$q_r$
$q_5$aaR$q_9$
$q_5$0,1,B--$q_r$
$q_6$11R$q_7$
$q_6$0,a,B--$q_r$
$q_7$aaR$q_{10}$
$q_7$0,1,B--$q_r$
$q_8$BB-$q_a$
$q_8$0,1,a--$q_r$
$q_9$BB-$q_a$
$q_9$0,1,a--$q_r$
$q_{10}$BB-$q_a$
$q_{10}$0,1,a--$q_r$

4. Transition Diagram

             a         0          1          a         B
  ->(q0) --------> (q1) ----> (q2) ----> (q3) ----> (q8) ----> ((qa))
                     | 1              a01a path |
                     v                          | 0
                   (q4)                         v
                     | 0                       (q6)
                     v                          | 1
                   (q5)                         v
                     | a                       (q7)
                     v                          | a
                   (q9)                         v
                     | B                      (q10)
                     v                          | B
                   ((qa))                       v
                                              ((qa))

(All undefined/unexpected inputs go to $q_r$, reject.)

5. Acceptance of a0101a

Tape: $B\ a\ 0\ 1\ 0\ 1\ a\ B$

StepStateHead readsActionNext
1$q_0$awrite a, R$q_1$
2$q_1$0write 0, R$q_2$
3$q_2$1write 1, R$q_3$
4$q_3$0write 0, R$q_6$
5$q_6$1write 1, R$q_7$
6$q_7$awrite a, R$q_{10}$
7$q_{10}$Bwrite B$q_a$

The machine halts in $q_a$ (final state), so the string a0101a is ACCEPTED. ✓

Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.