CSC262 · 2081 · 10 marks
Define Turing machine as enumerators of strings of a language. Encode the Turing machine TM = ({q0, q1, q2}, {a, b}, {a, b, B}, δ, q2, B, F) with input w = ba and δ is defined as follows: δ(q0, b) → (q1, b, R), δ(q1, a) → (q2, a, R), δ(q2, a) → (q1, a, R), δ(q2, b) → (q2, b, L)
Define Turing machine as enumerators of strings of a language. Encode the Turing machine TM = ({q0, q1, q2}, {a, b}, {a, b, B}, δ, q2, B, F) with input w = ba and δ is defined as follows: δ(q0, b) → (q1, b, R), δ(q1, a) → (q2, a, R), δ(q2, a) → (q1, a, R), δ(q2, b) → (q2, b, L)[10]
Turing Machine as Enumerator and Encoding
Part 1: Turing Machine as an Enumerator
A Turing machine used as an enumerator is a variant of the standard TM equipped with a work tape and a separate output tape (printer). Instead of taking an input and accepting/rejecting it, an enumerator $E$ starts on a blank tape and generates (lists) the strings of a language.
Working principle
- $E$ starts with all tapes blank (no input is provided).
- It computes, occasionally printing a string on the output tape followed by a separator symbol #.
- The set of all strings printed constitutes the language enumerated by $E$:
$$L(E) = {, w \mid E \text{ eventually prints } w \text{ on the output tape} ,}$$
- Strings may be printed in any order and may repeat.
Key theorem
A language $L$ is recursively enumerable (Turing recognizable) if and only if some enumerator $E$ enumerates it. Hence enumerators and recognizers define the same class of languages.
Part 2: Encoding the Given Turing Machine
Given data (extracted)
- States: $Q = {q_0, q_1, q_2}$
- Input alphabet: $\Sigma = {a, b}$
- Tape alphabet: $\Gamma = {a, b, B}$
- Start state: $q_2$
- Blank: $B$
- Final states: $F$ (not explicitly listed in question)
- Input: $w = ba$
- Transitions:
- $\delta(q_0, b) \to (q_1, b, R)$
- $\delta(q_1, a) \to (q_2, a, R)$
- $\delta(q_2, a) \to (q_1, a, R)$
- $\delta(q_2, b) \to (q_2, b, L)$
Note: the set $F$ of final states is not given, so it cannot be encoded. The encoding below covers states, symbols and transitions, which is what the data supports.
Step 1: Encode states (unary in 1's)
| State | Code |
|---|---|
| $q_0$ | $1$ |
| $q_1$ | $11$ |
| $q_2$ | $111$ |
Step 2: Encode tape symbols
| Symbol | Code |
|---|---|
| $a$ | $1$ |
| $b$ | $11$ |
| $B$ | $111$ |
Step 3: Encode directions
| Direction | Code |
|---|---|
| $L$ | $1$ |
| $R$ | $11$ |
Step 4: Encoding scheme
Each transition $\delta(q, s) \to (q', s', D)$ is encoded (fields separated by single $0$) as:
$$\text{code}(q),0,\text{code}(s),0,\text{code}(q'),0,\text{code}(s'),0,\text{code}(D)$$
T1: $\delta(q_0, b) \to (q_1, b, R)$ $$1,0,11,0,11,0,11,0,11$$
T2: $\delta(q_1, a) \to (q_2, a, R)$ $$11,0,1,0,111,0,1,0,11$$
T3: $\delta(q_2, a) \to (q_1, a, R)$ $$111,0,1,0,11,0,1,0,11$$
T4: $\delta(q_2, b) \to (q_2, b, L)$ $$111,0,11,0,111,0,11,0,1$$
Step 5: Full encoding (transitions separated by $00$)
$$\boxed{1,0,11,0,11,0,11,0,11 ; 00 ; 11,0,1,0,111,0,1,0,11 ; 00 ; 111,0,1,0,11,0,1,0,11 ; 00 ; 111,0,11,0,111,0,11,0,1}$$
Step 6: Trace on input $w = ba$ (start state $q_2$)
Tape: $B,b,a,B$, head on first symbol $b$, state $q_2$.
- Config 1: State $q_2$, read $b$. Apply $\delta(q_2,b)\to(q_2,b,L)$: write $b$, move Left. Head now on the blank $B$ to the left of $b$.
- Config 2: State $q_2$, read $B$. There is no transition for $(q_2, B)$, so the machine halts here.
Since $F$ is not specified, whether this halting configuration is accepting cannot be determined. With the given transitions, the computation halts after one move on the left blank, having never moved right into the $a$. Thus for start state $q_2$ the input $ba$ is not processed to completion in an accepting sense.
(Remark: if the intended start state were $q_0$, the trace would be $q_0 b a \Rightarrow q_1 a \Rightarrow q_2$ (blank) and halt for lack of a $(q_2,B)$ rule. The question explicitly gives start state $q_2$, so the trace above is the correct one for the stated data.)
Final result
- Enumerator: TM with output tape listing all strings of $L$, equivalent to recursive enumerability.
- Encoded string of the machine is the boxed binary string in Step 5.
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.