Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. ; Machine starts in state q0
  2.  
  3. ; State 0: change leftmost a symbol to _
  4. 0 _ * r 0
  5. 0 a _ * q1
  6. 0 b * * halt-reject
  7. 0 c * * halt-reject
  8.  
  9. ; State q1: Move to the right until first b is found
  10. q1 _ * r q1
  11. q1 a * r q1
  12. q1 b x * q2
  13. q1 x b * q5
  14. q1 c * * halt-reject
  15.  
  16. ; State q2: Move to the rightmost c
  17. q2 x * r q2
  18. q2 b * r q2
  19. q2 c * r q2
  20. q2 _ * l q3
  21.  
  22. ; State q3: delete rightmost c then move to the left,
  23. q3 c _ * q3
  24. q3 _ * l q4
  25. q3 b * l q3
  26. q3 x * r q1
  27.  
  28. ; State q4: check if there is a b, if not first check of _
  29. q4 c * l q4
  30. q4 b * l q3
  31. q4 x * l q4
  32. q4 a * l q5
  33. q4 _ * r q9
  34.  
  35. ; State q5: check if there is an a, if so repeat the loop but now b->x
  36. q5 a * l q5
  37. q5 _ * r 0
  38. q5 b * r q5
  39. q5 x * r q5
  40. q5 c * r q6
  41.  
  42. ; State q6: find the rightmost c with loop x->b
  43. q6 c * r q6
  44. q6 _ * l q7
  45.  
  46. ; State q7: delete rightmost c, also find an x to change it to b
  47. q7 c _ * q7
  48. q7 _ * l q8
  49. q7 x * l q7
  50. q7 b * r q1
  51.  
  52. ; State q8: move to the left until one a is found, also double-check x
  53. q8 c * l q8
  54. q8 x * l q7
  55. q8 b * l q8
  56. q8 a a * q5
  57. q8 _ * r q9 ; There are no more a's, check is zero c's aswell
  58.  
  59. ; State q9: check if there are no c's, if so, string is accepted
  60. q9 b * r q9
  61. q9 x * r q9
  62. q9 _ * * halt-accept
  63. q9 c * * halt-reject
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement