What is turing machine for $a^i b^j c^k$ where $i=j$ or $j=k$

1.8k Views Asked by At

I am trying to construct turing machine for $a^ib^jc^k$ where $i=j$ or $j=k$. Every time I come up with solution its getting fail for some other string.

1

There are 1 best solutions below

0
On

Assuming we are on the first character of the input string on the input tape (which is terminated on the left and right with at least one $0$ as sentinels), the following verifies that it matches $a^ib^jc^k$ with states 1-4, while already accepting the cases $i=j=0$ and $j=k=0$ and rejecting all other cases with $j=0$. If $k=0$, states 13-19 attempt to recognize $a^ib^i$. And if $i=0$, states 20-21 translate all $b$ and $c$ to $a$ and $b$ and then do the check for $a^ib^i$. The general case ($i,j,k>0$) is treated by removing one of each letters in a rigth to left scan in states 5-12, after which we start afresh.

It should be clear, but an entry $x\mapsto (y,z,w)$ is to be understood as: If the current field contains $x$ then write $z$, move in direction $w$ and switch to state $y$; an entry $x\mapsto \perp$ is understood as halt with negative answer; an entry $x\mapsto \top$ is understood as halt with positive answer. Any input letters not mentioned in a specific state are theoretically impossible to read in the given state; one may add them with $\mapsto\perp$ if one wishes.

  1. $a\mapsto (2,a,R)$, $b\mapsto (20,a,R)$, $c\mapsto \top$, $0\mapsto \top$
  2. $a\mapsto (2,a,R)$, $b\mapsto (3,b,R)$, $c\mapsto \perp$, $0\mapsto \top$
  3. $a\mapsto \perp$, $b\mapsto (3,b,R)$, $c\mapsto (4,c,R)$, $0\mapsto (13,0,L)$
  4. $a\mapsto \perp$, $b\mapsto \perp$, $c\mapsto (4,c,R)$, $0\mapsto (5,0,L)$
  5. $c\mapsto (6,0,L)$
  6. $b\mapsto (12,0,L)$, $c\mapsto (7,0,L)$
  7. $b\mapsto (9,0,L)$, $c\mapsto (8,0,L)$
  8. $b\mapsto (9,c,L)$, $c\mapsto (8,c,L)$
  9. $a\mapsto (11,c,L)$, $b\mapsto (10,c,L)$
  10. $a\mapsto (11,b,L)$, $b\mapsto (10,b,L)$
  11. $a\mapsto (11,a,L)$, $0\mapsto(1,0,R)$
  12. $a\mapsto (11,0,L)$, $b\mapsto(10,0,L)$
  13. $b\mapsto (14,0,L)$
  14. $a\mapsto (16,0,L)$, $b\mapsto (15,0,L)$
  15. $a\mapsto (16,b,L)$, $b\mapsto (15,b,L)$
  16. $a\mapsto (16,a,L)$, $0\mapsto(17,0,R)$
  17. $a\mapsto (18,a,R)$, $b\mapsto \perp$, $0\mapsto \top$
  18. $a\mapsto (18,a,R)$, $b\mapsto (19,b,R)$, $0\mapsto \perp$
  19. $b\mapsto (19,b,R)$, $0\mapsto (13,0,L)$
  20. $a\mapsto\perp$, $b\mapsto(20,a,R)$, $c\mapsto(21,b,R)$, $0\mapsto \perp$
  21. $a\mapsto\perp$, $b\mapsto\perp$, $c\mapsto(21,b,R)$, $0\mapsto(13,0,L)$