/* format: t(Current_state, Current_symbol, New_state, New_symbol, direction) */ start(s1). /* starting state */ t(s1,a,s2,x,r). /* in state s1 on an 'a', replace 'a' with 'x', enter s2, move right */ t(s2,a,s2,a,r). /* in state s2 move right until 'c' is passed */ t(s2,b,s2,b,r). t(s2,c,s3,c,r). /* when 'c' is encountered, enter s3 */ t(s3,x,s3,x,r). /* continue right, passing over all 'x' */ t(s3,a,s4,x,l). /* when the matching 'a' is found, change it to 'x' and go back left */ t(s4,x,s4,x,l). /* keep moving left to middle 'c' */ t(s4,c,s7,c,l). /* when 'c' is found, change states and keep moving left */ t(s7,a,s7,a,l). /* keep going left, passing over 'a' and 'b' */ t(s7,b,s7,b,l). t(s7,x,s1,x,r). /* when the 'x' is found, go back to initial state and move right */ t(s1,b,s5,x,r). /* similar to above when a 'b' is found */ t(s5,a,s5,a,r). t(s5,b,s5,b,r). t(s5,c,s6,c,r). t(s6,x,s6,x,r). t(s6,b,s4,x,l). t(s1,c,s8,c,r). /* when the last 'a' or 'b' on left is gone, make one last pass */ t(s8,x,s8,x,r). /* making sure all of the right side is 'x' */ t(s8,' ', s9,' ',l). accepting(s9).