0
$\begingroup$

I'm trying to design a Turing machine of the following specification:

Let Σ = {a, b}. Given a non-broken string composed of $a$'s and $b$'s, convert every contiguous string of two or more $b$’s to $a$’s, changing nothing else. Concretely, the string ‘$abbbbababb$’ is changed into ‘$aaaaaabaaa$.' The machine halts at the first blank square.

I can use a maximum of five states. Currently the two-or-more bit is throwing me off; when I try to flow-diagram the machine it gets quite complicated. Some guidance would be appreciated.

  • 0
    How about the following for the states: "converting-left", "reading-a", and "found-b". Do you need more than that?2017-02-14

2 Answers 2

0

I don't know the syntaxes used for turing machines, but the following should do it: $$\begin{array}{cc|lc} \text{State}&\text{Character}&\text{Action}&\text{Move}\\\hline 0 & a & \text{none} & \rightarrow\\ 0 & b & \text{State} = 1 & \rightarrow\\ 1 & a & \text{State} = 0 & \rightarrow\\ 1 & b & \text{State} = 2 & \rightarrow\\ 2 & a & \text{State} = 3 & \leftarrow\\ 2 & b & \text{none} & \rightarrow\\ 3 & a & \text{State} = 1 & \rightarrow\\ 3 & b & \text{Character} = a & \leftarrow \end{array}$$

States $0,1,2$ count the number of $b$s seen since the last $a$, topping off at $2$. State $3$ says it has reached the end of $b$s and it is time to go backwards, replacing each $b$ with $a$. When it runs into a character that is already $a$, it resets and starts going forward again.

0

Define 4 different states. Starting at $q_0$, if you see an $a$ return to $q_0$, else go to $q_1$ (in both instances move to the right). Here, if you see an $a$, go back to $q_0$ and move right, else go to $q_2$ and move right. At $q_2$, if you see a $b$, stay in $q_2$ and move right. If you see an $a$, go to $q_3$, move left. From $q_3$, if you see a $b$, overwrite it with $a$ and move left (stay in $q_3$). If you see an $a$, move to $q_0$ and move right.